首页 > 其他 > 详细

阿里短信服务的使用流程

时间:2019-07-23 19:14:13      阅读:98      评论:0      收藏:0      [点我收藏+]

阿里短信服务-使用流程

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、将相应的参数修改成变量

阿里短信服务的使用流程

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!