Commit 2e0f6044 authored by jim's avatar jim

resp

parent 3d9a0c0f
......@@ -17,14 +17,15 @@ public class SmsUtils {
private static final Logger log = LoggerFactory.getLogger(SmsUtils.class);
private static final int TIME_OUT=10*60; //10minues
private static final int TIME_OUT = 10 * 60; //10minues
/**
* Generate and send the SMS one time password to user's phone with SMS.
*
* @param phone
*/
public static String sendSmsOTP(String phone) {
String randomCode = createRandom(true,6);
String randomCode = createRandom(true, 6);
DefaultProfile profile = DefaultProfile.getProfile("default", "LTAIODPWRh6stFca", "0SBDR59HsquSDEj9CFXNt9njTs2cCv");
IAcsClient client = new DefaultAcsClient(profile);
......@@ -37,19 +38,20 @@ public class SmsUtils {
request.putQueryParameter("SignName", "防关联浏览器");
request.putQueryParameter("PhoneNumbers", phone);
request.putQueryParameter("TemplateCode", "SMS_185841618");
request.putQueryParameter("TemplateParam", "{\"code\":\""+randomCode+"\"}");
request.putQueryParameter("TemplateParam", "{\"code\":\"" + randomCode + "\"}");
try {
CommonResponse response = client.getCommonResponse(request);
if (response.getHttpStatus() == 200 && response.getData().contains("OK")) {
return randomCode;
} else {
log.error("fail to send sms {}", response.getData());
throw new ClientRequestException(AccountErrorCode.OTPSENDFAILS, AccountErrorCode.OTPSENDFAILS.getReason());
}
} catch (ServerException e) {
log.error("Sms sends failure",e);
log.error("Sms sends failure", e);
throw new ClientRequestException(AccountErrorCode.OTPSENDFAILS, AccountErrorCode.OTPSENDFAILS.getReason());
} catch (ClientException e) {
log.error("Sms sends failure",e);
log.error("Sms sends failure", e);
throw new ClientRequestException(AccountErrorCode.OTPSENDFAILS, AccountErrorCode.OTPSENDFAILS.getReason());
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment