Java后台做 短信验证码、短信通知,阿里云短信服务

Java+阿里云短信实现系统登录发送验证码功能
阿里云短信服务器地址:
1、申请签名,等待审核通过
2、按需选择你要的短信类型,创建一个短信模板 。
3、等待审核通过,其中“模版CODE”是我们需要的字段
4、与获取方法
以上材料准备好之后,就进入后台开发
Java后台代码
阿里云官方API:
1、pom.xml
com.aliyunaliyun-java-sdk-core4.0.3
2、.java
import com.aliyuncs.CommonRequest;import com.aliyuncs.CommonResponse;import com.aliyuncs.DefaultAcsClient;import com.aliyuncs.IAcsClient;import com.aliyuncs.exceptions.ClientException;import com.aliyuncs.exceptions.ServerException;import com.aliyuncs.http.MethodType;import com.aliyuncs.profile.DefaultProfile;/*** 正常报文{"Message":"OK","RequestId":"DEE155B3-80C4-46B8-B251-2D6CBCF845B1","BizId":"134918351688579152^0","Code":"OK"}*/public class CommonRpc {public static void main(String[] args) {DefaultProfile profile = DefaultProfile.getProfile("default", "", "");IAcsClient client = new DefaultAcsClient(profile);CommonRequest request = new CommonRequest();//request.setProtocol(ProtocolType.HTTPS);request.setMethod(MethodType.POST);request.setDomain("dysmsapi.aliyuncs.com");request.setVersion("2017-05-25");request.setAction("SendSms");request.putQueryParameter("PhoneNumbers", "手机号码");request.putQueryParameter("SignName", "签名名称");request.putQueryParameter("TemplateCode", "短信模板ID");request.putQueryParameter("TemplateParam", "短信模板中对应的变量值对(json类型的参数值)");try {CommonResponse response = client.getCommonResponse(request);System.out.println(response.getData());} catch (ServerException e) {e.printStackTrace();} catch (ClientException e) {e.printStackTrace();}}}
3、短信正常发送后的结果集:{“”:“OK”,“”:“-5072-4941-A7ED-”,“BizId”:“^0”,“Code”:“OK”}
【Java后台做 短信验证码、短信通知,阿里云短信服务】4、手机收到验证码提醒