52 lines
1.7 KiB
Plaintext
52 lines
1.7 KiB
Plaintext
|
|
package com.nationalelectric.greenH5.utils;
|
||
|
|
|
||
|
|
import com.ipi.cloud.interfaces.dto.ErrorInfo;
|
||
|
|
import com.ipi.cloud.sms.access.vo.SmsAccount;
|
||
|
|
import com.ipi.cloud.sms.access.vo.response.SmsBatchSmbitResult;
|
||
|
|
import com.ipi.cloud.sms.access.vo.response.SmsBatchSumbitResponse;
|
||
|
|
import com.nationalelectirc.Constant.Constant;
|
||
|
|
public class SmsUtils {
|
||
|
|
|
||
|
|
|
||
|
|
public static String sendSms(String phone, String content) {
|
||
|
|
try {
|
||
|
|
|
||
|
|
// 接口地址
|
||
|
|
String interUrl = "http://interface.i314.net:6666/interface/SendMsg";
|
||
|
|
// 企业编号
|
||
|
|
String entNo = "21511357814001";
|
||
|
|
// 用户账号
|
||
|
|
String account = "Jysoft";
|
||
|
|
// 用户密码
|
||
|
|
String password = "Jysoft123456";
|
||
|
|
|
||
|
|
// 目标号码,多个用英文逗号隔开
|
||
|
|
String destPhone = phone;
|
||
|
|
// 短信内容
|
||
|
|
String msg = content;
|
||
|
|
|
||
|
|
// 指定签名
|
||
|
|
String sign = "S191223162714666006";
|
||
|
|
|
||
|
|
/*** 调用接口进行请求批量发送 ***/
|
||
|
|
SmsBatchSumbitResponse resp = com.ipi.cloud.sms.access.request.CloudSmsCore.getInstance().batchSendSms(interUrl, new SmsAccount(entNo, account, password), destPhone, msg, sign);
|
||
|
|
if (resp.isSuccess()) // 提交成功
|
||
|
|
{
|
||
|
|
SmsBatchSmbitResult result = resp.getBatchSmbitResult();
|
||
|
|
// 根据结果进行业务处理
|
||
|
|
System.out.println("Sms result---->" + result);
|
||
|
|
return Constant.SUCCESS;
|
||
|
|
} else { // 提交返回错误
|
||
|
|
ErrorInfo errorInfo = resp.getErrorInfo();
|
||
|
|
// 根据结果进行相关错误处理
|
||
|
|
System.out.println("SmsError--->" + errorInfo);
|
||
|
|
return Constant.FAILED;
|
||
|
|
}
|
||
|
|
} catch (Exception e) {
|
||
|
|
System.out.println(e.getMessage());
|
||
|
|
return Constant.FAILED;
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
}
|