码迷,mamicode.com
首页 > 其他好文 > 详细

阿里短信服务的使用流程

时间:2019-07-23 18:53:37      阅读:416      评论:0      收藏:0      [点我收藏+]

标签:ram   expand   color   scl   demo   ret   ali   yun   put   

阿里短信服务-使用流程

1、注册阿里账号

2、获得accessKeyId和accessKeySecret

3、创建SmsSendUtil工具类

4、创建sendSms方法

5、将阿里发短信Demo核心代码复制为sendSms的方法体内

 DefaultProfile profile = DefaultProfile.getProfile("cn-hangzhou", "<accessKeyId>", "<accessSecret>");
        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", "177******75");
        request.putQueryParameter("SignName", "云商商城");
        request.putQueryParameter("TemplateCode", "SMS_171110064");
        request.putQueryParameter("TemplateParam", "{\"code\":\"6666\"}");
        try {
            CommonResponse response = client.getCommonResponse(request);
            System.out.println(response.getData());
        } catch (ServerException e) {
            e.printStackTrace();
        } catch (ClientException e) {
            e.printStackTrace();
        }

6、将相应的参数修改成变量

阿里短信服务的使用流程

标签:ram   expand   color   scl   demo   ret   ali   yun   put   

原文地址:https://www.cnblogs.com/kitor/p/11233619.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!