|
|
@@ -45,6 +45,9 @@ public class SmsUtil {
|
|
|
//国际腾讯云短信
|
|
|
private static final String TENCENT_SMS_INTERNATIONAL_TEMPLATE_ID = "1705927";
|
|
|
|
|
|
+ //账号修改密码国际短信通知
|
|
|
+ private static final String TENCENT_SMS_ACCOUNT_INTERNATIONAL_TEMPLATE_ID = "2040574";
|
|
|
+
|
|
|
private static final Logger log = LoggerFactory.getLogger(SmsUtil.class);
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
@@ -94,6 +97,19 @@ public class SmsUtil {
|
|
|
}
|
|
|
|
|
|
public static Boolean sendTencent(Integer cid, String mobile, String msg) {
|
|
|
+ String templateId = TENCENT_SMS_TEMPLATE_ID;
|
|
|
+ if (cid != 86) {
|
|
|
+ templateId = TENCENT_SMS_INTERNATIONAL_TEMPLATE_ID;
|
|
|
+ }
|
|
|
+ return commonSendTencentSmsMsg(templateId, cid, mobile, msg);
|
|
|
+ }
|
|
|
+
|
|
|
+ public static Boolean sendAccountInternalSmsMsg(Integer cid, String mobile, String msg) {
|
|
|
+ String templateId = TENCENT_SMS_ACCOUNT_INTERNATIONAL_TEMPLATE_ID;
|
|
|
+ return commonSendTencentSmsMsg(templateId, cid, mobile, msg);
|
|
|
+ }
|
|
|
+
|
|
|
+ public static Boolean commonSendTencentSmsMsg(String templateId, Integer cid, String mobile, String msg) {
|
|
|
try {
|
|
|
/* 必要步骤:
|
|
|
* 实例化一个认证对象,入参需要传入腾讯云账户密钥对secretId,secretKey。
|
|
|
@@ -108,8 +124,8 @@ public class SmsUtil {
|
|
|
* 如有需要请在代码中查阅以获取最新的默认值 */
|
|
|
httpProfile.setConnTimeout(60);
|
|
|
/* 指定接入地域域名,默认就近地域接入域名为 sms.tencentcloudapi.com ,也支持指定地域域名访问,例如广州地域的域名为 sms.ap-guangzhou.tencentcloudapi.com
|
|
|
- * 南京地域
|
|
|
- * */
|
|
|
+ * 南京地域
|
|
|
+ * */
|
|
|
httpProfile.setEndpoint("sms.ap-nanjing.tencentcloudapi.com");
|
|
|
|
|
|
/* 非必要步骤:
|
|
|
@@ -138,10 +154,6 @@ public class SmsUtil {
|
|
|
req.setSignName(TENCENT_SMS_SIGN_NAME);
|
|
|
|
|
|
/* 模板 ID: 必须填写已审核通过的模板 ID */
|
|
|
- String templateId = TENCENT_SMS_TEMPLATE_ID;
|
|
|
- if (cid != 86) {
|
|
|
- templateId = TENCENT_SMS_INTERNATIONAL_TEMPLATE_ID;
|
|
|
- }
|
|
|
req.setTemplateId(templateId);
|
|
|
|
|
|
/* 模板参数: 模板参数的个数需要与 TemplateId 对应模板的变量个数保持一致,若无模板参数,则设置为空 */
|
|
|
@@ -164,7 +176,6 @@ public class SmsUtil {
|
|
|
if ("Ok".equalsIgnoreCase(sendStatus.getCode())) {
|
|
|
return true;
|
|
|
}
|
|
|
- return false;
|
|
|
|
|
|
// 也可以取出单个值,你可以通过官网接口文档或跳转到response对象的定义处查看返回字段的定义
|
|
|
// System.out.println(res.getRequestId());
|