From 4c99ee7028c3fe58a2cd4b8273b22c75c45574fc Mon Sep 17 00:00:00 2001
From: Pu Zhibing <393733352@qq.com>
Date: 星期五, 16 五月 2025 10:27:41 +0800
Subject: [PATCH] 修改文档bug

---
 UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/SMSUtil.java |   91 +++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 90 insertions(+), 1 deletions(-)

diff --git a/UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/SMSUtil.java b/UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/SMSUtil.java
index e38beff..32b7688 100644
--- a/UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/SMSUtil.java
+++ b/UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/SMSUtil.java
@@ -1,6 +1,18 @@
 package com.stylefeng.guns.modular.system.util;
 
 
+import cn.hutool.http.ContentType;
+import cn.hutool.http.HttpRequest;
+import cn.hutool.http.HttpResponse;
+import cn.hutool.http.HttpUtil;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.twilio.Twilio;
+import com.twilio.rest.api.v2010.account.Message;
+import com.twilio.type.PhoneNumber;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
 import javax.net.ssl.*;
 import java.io.*;
 import java.net.URL;
@@ -12,6 +24,7 @@
 import java.text.SimpleDateFormat;
 import java.util.*;
 
+@Component
 public class SMSUtil {
 
     //无需修改,用于格式化鉴权头域,给"X-WSSE"参数赋值
@@ -30,7 +43,7 @@
     public static void send_huawei_sms(String templateId, String receiver, String templateParas) throws Exception {
 
         //必填,请参考"开发准备"获取如下数据,替换为实际值
-        String url = "https://smsapi.cn-south-1.myhuaweicloud.com:443"; //APP接入地址(在控制台"应用管理"页面获取)+接口访问URI
+        String url = "https://smsapi.cn-south-1.myhuaweicloud.com:443/sms/batchSendSms/v1"; //APP接入地址(在控制台"应用管理"页面获取)+接口访问URI
         String appKey = "g3DW0G5Fbp3110UiGl5fkWcn799s"; //APP_Key
         String appSecret = "LaT1NYvQKNkHO5KikniEueN8iTaz"; //APP_Secret
         String sender = "ismsapp0000000103"; //国内短信签名通道号或国际/港澳台短信通道号
@@ -226,4 +239,80 @@
         sc.init(null, trustAllCerts, null);
         HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
     }
+
+
+    /**
+     * 发送Twilio短信
+     * @param toPhone
+     * @param msg
+     * @return
+     */
+    public static boolean sendTwilioMessage(String toPhone, String msg){
+        String ACCOUNT_SID = "AC1fd05e898bd59d17ba72db621afca537";
+        String AUTH_TOKEN = "7cee1a6cb0e2936a9037be577b1ffe57";
+        String formPhone = "+16672740015";
+        try {
+            Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
+            Message message = Message.creator(
+                    new PhoneNumber(toPhone),
+                    new PhoneNumber(formPhone),
+                    msg
+            ).create();
+            System.out.println(message.getSid());
+            Message.Status status = message.getStatus();
+            switch (status.toString()){
+                case "canceled":
+                    return false;
+                case "undelivered":
+                    return false;
+                case "failed":
+                    return false;
+            }
+            return true;
+        }catch (Exception e){
+            e.printStackTrace();
+            return false;
+        }
+    }
+
+
+    /**
+     * 短信 : https://sms.mymailcentre.com
+     * API:https://documenter.getpostman.com/view/7705958/Uyr7Hydn
+     * @param toPhone
+     * @param msg
+     * @return
+     */
+    public boolean sendCellulantMessage(String toPhone, String msg){
+        String url = "https://sms.nalosolutions.com/smsbackend/Resl_Nalo/send-message/";
+        HttpRequest post = HttpUtil.createPost(url);
+        post.contentType(ContentType.JSON.toString());
+        JSONObject params = new JSONObject();
+        params.put("username", "I-GO");
+        params.put("password", "9wBolBiXskCuzSf");
+        params.put("msisdn", toPhone);
+        params.put("message", msg);
+        params.put("sender_id", "I-GO");
+        params.put("callback_url", "https://igo.i-go.group/user/base/sendCellulantMessageCallback");
+        params.put("validity", 1);
+        post.body(params.toJSONString());
+        System.err.println("短信请求:\n请求地址:" + url + "\n请求参数:" + params.toJSONString());
+        HttpResponse execute = post.execute();
+        String body = execute.body();
+        execute.close();
+        JSONObject jsonObject = JSON.parseObject(body);
+        System.err.println("短信响应:" + body);
+        Integer status = jsonObject.getInteger("status");
+        if(null != status && 1701 == status){
+            return true;
+        }else{
+            return false;
+        }
+    }
+    
+    public static void main(String[] ages){
+        //{"callback_url":"https://igo.i-go.group/user/base/sendCellulantMessageCallback","msisdn":"233244915521","message":"Your verification code is 2358,it is valid within 5 minutes, please do not reveal it to others.","key":"ru#0flkf3993qh!!rg!@y4)nhwi08c#tg_vasek!ja)kvfnfjyoljoz(@nai(jkf","sender_id":"I-GO"}
+        SMSUtil smsUtil = new SMSUtil();
+        smsUtil.sendCellulantMessage("233244915521", "Your verification code is 2358,it is valid within 5 minutes, please do not reveal it to others.");
+    }
 }

--
Gitblit v1.7.1