短信发送,智能门锁待知
package com.bnb;
import com.alibaba.fastjson.JSONObject;
import com.aliyuncs.CommonRequest;
import com.aliyuncs.CommonResponse;
import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.http.MethodType;
import com.aliyuncs.profile.DefaultProfile;
import org.junit.Test;
import java.rmi.ServerException;
import java.util.HashMap;
public class AddSmsSign {
public static void main(String[] args) {
for(int i=0;i<5;i++){
DefaultProfile profile = DefaultProfile.getProfile("****", "******", "*******");
IAcsClient client = new DefaultAcsClient(profile);
CommonRequest request = new CommonRequest();
request.setSysMethod(MethodType.POST);
request.setSysDomain("dysmsapi.aliyuncs.com");
request.setSysVersion("2017-05-25");
request.setSysAction("SendSms");
request.putQueryParameter("PhoneNumbers", "手机号");
request.putQueryParameter("SignName", "******");
request.putQueryParameter("TemplateCode", "*****");
HashMap<String, Object> map = new HashMap<>();
map.put("content",1233);
request.putQueryParameter("TemplateParam",JSONObject.toJSONString(map));
try {
CommonResponse response = client.getCommonResponse(request);
System.out.println(response.getData());
} catch (ClientException e) {
e.printStackTrace();
}
}}
}
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-core</artifactId>
<version>4.5.3</version>
</dependency>