请问使用短信服务发短信提示如下怎么解决?
Re请问使用短信服务发短信提示如下怎么解决?
public static String sendSms() throws ClientException {
String result = '';
try {
IClientProfile profile = DefaultProfile.getProfile('cn-hangzhou', 'XXX',
'XXX');
DefaultProfile.addEndpoint('cn-hangzhou', 'cn-hangzhou', 'Sms', 'sms.aliyuncs.com');
IAcsClient client = new DefaultAcsClient(profile);
SingleSendSmsRequest request = new SingleSendSmsRequest();
request.setSignName('XXX');// 控制台创建的签名名称
request.setTemplateCode('XXX');// 控制台创建的模板CODE
request.setParamString('{\'code\':\'123456\'}');// 短信模板中的变量;数字需要转换为字符串;个人用户每个变量长度必须小于15个字符。'
// request.setParamString('{}');
request.setAcceptFormat(FormatType.JSON); // 格式为json
request.setRecNum('XXXX');// 接收号码
SingleSendSmsResponse httpResponse = client.getAcsResponse(request);
System.out.println(httpResponse);
result = 'true';
} catch (ClientException e) {
result = e.getErrCode();
e.printStackTrace();
}
return result;
}
赞0
踩0