From 868055044602d71a51708947366a022f02b79a60 Mon Sep 17 00:00:00 2001 From: "1215525055@qq.com" <1215525055@qq.com> Date: Wed, 5 Mar 2025 00:00:18 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=94=B9=E7=9F=AD=E4=BF=A1=E5=8F=91?= =?UTF-8?q?=E9=80=81=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/tenlion/operator/util/TenlionSMS.java | 51 +++++++++++-------- 1 file changed, 29 insertions(+), 22 deletions(-) diff --git a/src/main/java/cn/com/tenlion/operator/util/TenlionSMS.java b/src/main/java/cn/com/tenlion/operator/util/TenlionSMS.java index a22aeb3..5c4b08e 100644 --- a/src/main/java/cn/com/tenlion/operator/util/TenlionSMS.java +++ b/src/main/java/cn/com/tenlion/operator/util/TenlionSMS.java @@ -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 templateParams = new HashMap(); - 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 templateParams = new HashMap(); + 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();