public class SMSUtils {
public static final String VALIDATE_CODE = "SMS_190900306";
public static void sendShortMessage(String templateCode,String phoneNumbers,String param) throws ClientException{
System.setProperty("sun.net.client.defaultConnectTimeout", "10000");
System.setProperty("sun.net.client.defaultReadTimeout", "10000");
final String product = "Dysmsapi";
final String domain = "dysmsapi.aliyuncs.com";
final String accessKeyId = "LTAI6IIhdkcufkHS";
final String accessKeySecret = "SutVEczYsOsoHYUSyxgyqirjelve0C";
IClientProfile profile = DefaultProfile.getProfile("cn-hangzhou", accessKeyId, accessKeySecret);
DefaultProfile.addEndpoint("cn-hangzhou", "cn-hangzhou", product, domain);
IAcsClient acsClient = new DefaultAcsClient(profile);
SendSmsRequest request = new SendSmsRequest();
request.setMethod(MethodType.POST);
request.setPhoneNumbers(phoneNumbers);
request.setSignName("?????");
request.setTemplateCode(templateCode);
request.setTemplateParam("{\"code\":\""+param+"\"}");
SendSmsResponse sendSmsResponse = acsClient.getAcsResponse(request);
if (sendSmsResponse.getCode() != null && sendSmsResponse.getCode().equals("OK")) {
System.out.println("请求成功");
}
}
}