|
@@ -1,5 +1,6 @@
|
|
|
package com.rongwei.bscommon.sys.utils;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.rongwei.rwcommon.utils.StringUtils;
|
|
|
import org.apache.commons.codec.binary.Hex;
|
|
@@ -46,8 +47,11 @@ public class HwSmsUtil {
|
|
|
// TEMPLATE_ID = templateId;
|
|
|
// }
|
|
|
public static void main(String[] args) throws Exception{
|
|
|
-
|
|
|
- sendSms("7133b7ce87a84896a143b02edf5a4757","8823102504763", "13720166098,13720166098","13720166098");
|
|
|
+ List<String> list = new ArrayList<>();
|
|
|
+ list.add("123asd");
|
|
|
+ list.add("123asd");
|
|
|
+ String s = JSON.toJSON(list).toString();
|
|
|
+ sendSms("8a3df3ba13e94963a9b028185877a136","8823102504763", list,"13720166098");
|
|
|
// sendSms("[\"17623778642\",\"蓉A-7823\"]","17623778642","8819122535459","6c848255000c4619833ab690e393f906");
|
|
|
// sendSms("[\"17623778642\",\"蓉A-7823\",\"2019/12/27\",\"14:00\"]","17623778642","8819122535459","bb13d00d11e043659001a89c72d54cab");
|
|
|
}
|
|
@@ -61,7 +65,7 @@ public class HwSmsUtil {
|
|
|
* @throws Exception
|
|
|
* @return
|
|
|
*/
|
|
|
- public static JSONObject sendSms(String templateId,String sender, String code, String phone) throws Exception{
|
|
|
+ public static JSONObject sendSms(String templateId,String sender, List<String> code, String phone) throws Exception{
|
|
|
//必填,请参考"开发准备"获取如下数据,替换为实际值
|
|
|
String url = "https://smsapi.cn-south-1.myhuaweicloud.com:443/sms/batchSendSms/v1"; //APP接入地址+接口访问URI
|
|
|
String appKey = "iZA4u69023CpkvGGxrXxrBuNMp1B"; //APP_Key
|
|
@@ -89,7 +93,7 @@ public class HwSmsUtil {
|
|
|
* ${DATE}${TIME}变量不允许取值为空,${TXT_20}变量可以使用英文空格或点号替代空值,${NUM_6}变量可以使用0替代空值
|
|
|
* 查看更多模板和变量规范:产品介绍>模板和变量规范
|
|
|
*/
|
|
|
- String templateParas = "["+code+"]"; //模板变量
|
|
|
+ String templateParas = JSON.toJSON(code).toString();; //模板变量
|
|
|
|
|
|
//请求Body,不携带签名名称时,signature请填null
|
|
|
String body = buildRequestBody(sender, receiver, templateId, templateParas, statusCallBack, signature);
|