阿里云短信发送

阿里云自带 debug 短信调节器:

https://api.aliyun.com/new#/?product=Dysmsapi&api=SendSms 

 

第一步:开通阿里云短信接口服务

https://dysms.console.aliyun.com/dysms.htm?spm=5176.12818093.recent.ddysms.488716d0DkRAjk#/overview

第二步:创建AccessKeyID和AccessKeySecret    用户区分云服务账号

AccessKeyID:LTAI4FwLvbaMLSYLE9E9TNoYFb 【类似】
AccessKeySecret:OLkCtYpRCtO8EfZ6GWUT042pPEl09v9G 【类似】

 第三步:添加签名【短信的开头:】 和 模板【发送类型】

签名图参:【审核下来时长:2-4小时】

 

模板图参:【审核下来时长:1-2小时】


 


 

参考代码:

DefaultProfile profile = DefaultProfile.getProfile("cn-hangzhou", "AccessKeyID", "AccessKeySecret");
        IAcsClient client = new DefaultAcsClient(profile);
        CommonRequest request = new CommonRequest();
        request.setMethod(MethodType.POST);
        request.setDomain("dysmsapi.aliyuncs.com");
        request.setVersion("2017-05-25");
        request.setAction("SendSms");
        request.putQueryParameter("RegionId", "cn-hangzhou");
        request.putQueryParameter("PhoneNumbers", tel);
        request.putQueryParameter("SignName", "签名");
        request.putQueryParameter("TemplateCode", "模板id");
        //模板参数 ${code}    
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("code",yzm);
        jsonObject.put("product","自定义参数");
        request.putQueryParameter("TemplateParam", jsonObject.toString());
        try {
            CommonResponse response = client.getCommonResponse(request);
            JSONObject jsonObject2 = new JSONObject(response.getData());
            String Message = jsonObject2.getString("Message");
           return  Message;
        } catch (ServerException e) {
            e.printStackTrace();
        } catch (ClientException e) {
            e.printStackTrace();
        }

maven  jar 文件:

<dependency>
    <groupId>com.aliyun</groupId>
    <artifactId>aliyun-java-sdk-core</artifactId>
    <version>4.0.3</version>
</dependency>

 

 

 

 

 

 

 

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

wait_for_me

你的鼓励是我最大的动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值