更改短信发送地址

This commit is contained in:
1215525055@qq.com 2025-03-05 00:00:18 +08:00
parent ba10e85b81
commit 8680550446

View File

@ -1,9 +1,11 @@
package cn.com.tenlion.operator.util;
import cn.com.tenlion.operator.properties.SystemApiPathProperties;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
@ -22,12 +24,12 @@ import java.util.UUID;
* 崔宝铖 2023年5月12日11:28:11
*/
public class TenlionSMS {
private static String smsKey = "73bd027a-b9f0-44ac-a414-984baf23f988";
private static String smsSecret = "BMAF4tiD+QoB1rK7AMC4nuRWISbf83Tc";
private static String systemUrl = "http://192.168.0.115:8099/operator-plugin";
private static String systemUrl = "";
// 短信发送地址
private static String sendSMSUrl = systemUrl + "/app/send";
// 短信状态查询地址
@ -43,26 +45,31 @@ public class TenlionSMS {
if (systemUrl.endsWith("/")) {
systemUrl = systemUrl.substring(0, systemUrl.length() -1);
}
sendSMSUrl = systemUrl + "/app/send";
getStatusSMSUrl = systemUrl + "/app/send/status";
getReplySMSUrl = systemUrl + "/app/send/reply";
getTemplateSMSUrl = systemUrl + "/app/send/template";
}
public static void main(String[] args) {
// 可用模板列表
// System.out.println(getTemplate());
// 短信发送
String uuid = UUID.randomUUID().toString();
Map<String, String> templateParams = new HashMap<String, String>();
templateParams.put("content", "您的验证码是123356");
JSONArray phoneArray = new JSONArray();
JSONObject obj1 = new JSONObject();
obj1.put("phone", "17691030315");
phoneArray.add(obj1);
System.out.println(sendMessage(uuid, "M00002", templateParams, phoneArray));
// 短信回复查询
System.out.println(getMessageReply(uuid, "17691030315"));
public static void main(String[] args) {
// 可用模板列表
// System.out.println(getTemplate());
// 短信发送
String uuid = UUID.randomUUID().toString();
Map<String, String> templateParams = new HashMap<String, String>();
templateParams.put("content", "您的验证码是123356");
JSONArray phoneArray = new JSONArray();
JSONObject obj1 = new JSONObject();
obj1.put("phone", "17691030315");
phoneArray.add(obj1);
System.out.println(sendMessage(uuid, "M00002", templateParams, phoneArray));
// 短信回复查询
System.out.println(getMessageReply(uuid, "17691030315"));
// 短信状态查询
// System.out.println(getMessageStatus("26800e6c-004a-4d77-bac2-3f80c70a423d", "17691030315"));
}
/**
* 获取模板列表
* @return
@ -85,7 +92,7 @@ public class TenlionSMS {
}
return result;
}
/**
* 短信回复查询
* @param smsNO 36位UUID
@ -110,7 +117,7 @@ public class TenlionSMS {
}
return result;
}
/**
* 短信状态查询
* @param smsNO 36位UUID
@ -136,7 +143,7 @@ public class TenlionSMS {
return result;
}
/**
* 短信发送
* @param smsNO 36位UUID
@ -151,7 +158,7 @@ public class TenlionSMS {
jsonObject.put("phoneArray", phoneArray);
jsonObject.put("templateParams", templateParams);
// jsonPost请求
HttpPost httpPost = new HttpPost(sendSMSUrl + "/" + templateCode);
HttpPost httpPost = new HttpPost(sendSMSUrl + "/" + templateCode);
httpPost.addHeader("smsKey", smsKey);
httpPost.addHeader("smsSecret", smsSecret);
CloseableHttpClient client = HttpClients.createDefault();
@ -168,7 +175,7 @@ public class TenlionSMS {
result = JSON.parseObject(body);
System.out.println("返回结果:" + result.toJSONString());
if("200".equals(result.getString("code"))){
return true;
return true;
}
} catch (IOException e) {
e.printStackTrace();