md
This commit is contained in:
parent
9898044bb6
commit
f8c027b3f8
@ -24,14 +24,13 @@ public class AliyunSMSService {
|
|||||||
*/
|
*/
|
||||||
public int sendMessage(String signName,String phone, String templateCode,String tplParam) throws EmisBizError {
|
public int sendMessage(String signName,String phone, String templateCode,String tplParam) throws EmisBizError {
|
||||||
|
|
||||||
// String jsonParamStr=configService.selectConfigByKey("sys.aliyun.sms");
|
String jsonParamStr=configService.selectConfigByKey("sys.aliyun.sms");
|
||||||
// JSONObject jObjAliyunParam=JSONObject.parseObject(jsonParamStr);
|
JSONObject jObjAliyunParam=JSONObject.parseObject(jsonParamStr);
|
||||||
// String accessKeyId=jObjAliyunParam.getString("accessKeyId");
|
String accessKeyId=jObjAliyunParam.getString("accessKeyId");
|
||||||
// String accessKeySecret=jObjAliyunParam.getString("accessKeySecret");
|
String accessKeySecret=jObjAliyunParam.getString("accessKeySecret");
|
||||||
//
|
|
||||||
// return innerSendMessage(accessKeyId,accessKeySecret,signName,templateCode,phone,tplParam);
|
return innerSendMessage(accessKeyId,accessKeySecret,signName,templateCode,phone,tplParam);
|
||||||
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,42 +41,41 @@ public class AliyunSMSService {
|
|||||||
* @return Client
|
* @return Client
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
// public static Client createClient(String accessKeyId, String accessKeySecret) throws Exception {
|
public static Client createClient(String accessKeyId, String accessKeySecret) throws Exception {
|
||||||
// com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config()
|
com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config()
|
||||||
// .setAccessKeyId(accessKeyId)
|
.setAccessKeyId(accessKeyId)
|
||||||
// .setAccessKeySecret(accessKeySecret);
|
.setAccessKeySecret(accessKeySecret);
|
||||||
// // 访问的域名
|
// 访问的域名
|
||||||
// config.endpoint = "dysmsapi.aliyuncs.com";
|
config.endpoint = "dysmsapi.aliyuncs.com";
|
||||||
// return new Client(config);
|
return new Client(config);
|
||||||
// return null;
|
}
|
||||||
// }
|
|
||||||
|
|
||||||
public static int innerSendMessage(String accessKeyId,String accessKeySecret,String signName,String templateCode, String phone, String tplParam) throws EmisBizError {
|
public static int innerSendMessage(String accessKeyId,String accessKeySecret,String signName,String templateCode, String phone, String tplParam) throws EmisBizError {
|
||||||
// try {
|
try {
|
||||||
// Client client = createClient(accessKeyId, accessKeySecret);
|
Client client = createClient(accessKeyId, accessKeySecret);
|
||||||
// com.aliyun.dysmsapi20170525.models.SendSmsRequest sendSmsRequest = new com.aliyun.dysmsapi20170525.models.SendSmsRequest();
|
com.aliyun.dysmsapi20170525.models.SendSmsRequest sendSmsRequest = new com.aliyun.dysmsapi20170525.models.SendSmsRequest();
|
||||||
// sendSmsRequest.setPhoneNumbers(phone);
|
sendSmsRequest.setPhoneNumbers(phone);
|
||||||
// sendSmsRequest.setSignName(signName);
|
sendSmsRequest.setSignName(signName);
|
||||||
// sendSmsRequest.setTemplateCode(templateCode);
|
sendSmsRequest.setTemplateCode(templateCode);
|
||||||
//// sendSmsRequest.setTemplateParam("{\"code\":\""+param+"\"}");
|
// sendSmsRequest.setTemplateParam("{\"code\":\""+param+"\"}");
|
||||||
// sendSmsRequest.setTemplateParam(tplParam);
|
sendSmsRequest.setTemplateParam(tplParam);
|
||||||
// RuntimeOptions runtime = new RuntimeOptions();
|
RuntimeOptions runtime = new RuntimeOptions();
|
||||||
// com.aliyun.dysmsapi20170525.models.SendSmsResponse response = client.sendSmsWithOptions(sendSmsRequest, runtime);
|
com.aliyun.dysmsapi20170525.models.SendSmsResponse response = client.sendSmsWithOptions(sendSmsRequest, runtime);
|
||||||
// String jsonStr= Common.toJSONString(TeaModel.buildMap(response));
|
String jsonStr= Common.toJSONString(TeaModel.buildMap(response));
|
||||||
//
|
|
||||||
// if(response.getStatusCode()==200) {
|
if(response.getStatusCode()==200) {
|
||||||
// if ("OK".equals(response.getBody().getCode())) {
|
if ("OK".equals(response.getBody().getCode())) {
|
||||||
// return 1;
|
return 1;
|
||||||
// } else {
|
} else {
|
||||||
// throw new EmisBizError(EmisBizErrorType.FAIL,response.getBody().getMessage());
|
throw new EmisBizError(EmisBizErrorType.FAIL,response.getBody().getMessage());
|
||||||
// }
|
}
|
||||||
// }else{
|
}else{
|
||||||
// throw new EmisBizError(EmisBizErrorType.FAIL,"短信渠道发送错误");
|
throw new EmisBizError(EmisBizErrorType.FAIL,"短信渠道发送错误");
|
||||||
// }
|
}
|
||||||
// }catch (Exception e) {
|
}catch (Exception e) {
|
||||||
// e.printStackTrace();
|
e.printStackTrace();
|
||||||
// throw new EmisBizError(EmisBizErrorType.FAIL,"短信渠道异常");
|
throw new EmisBizError(EmisBizErrorType.FAIL,"短信渠道异常");
|
||||||
// }
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user