From 49e88798dcea0164f77c59f0be9eefdf67a3d228 Mon Sep 17 00:00:00 2001
From: 无关风月 <443237572@qq.com>
Date: 星期三, 17 七月 2024 15:03:10 +0800
Subject: [PATCH] 2.0bug修改
---
UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/SMSUtil.java | 59 ++++++++++++++++++++++-------------------------------------
1 files changed, 22 insertions(+), 37 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 c927df5..656d303 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,10 @@
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;
@@ -271,59 +275,40 @@
}
}
- @Autowired
- private HttpClientUtil httpClientUtil;
-
/**
- * Cellulant短信
+ * 短信 : https://www.nalosolutions.com/
* @param toPhone
* @param msg
* @return
*/
public boolean sendCellulantMessage(String toPhone, String msg){
- String url = "https://sms.nalosolutions.com/smsbackend/Nal_resl/send-message/";
- Map<String, Object> params = new HashMap<>();
+ String url = "https://sms.nalosolutions.com/smsbackend/clientapi/Cell_resl/send-message/";
+ HttpRequest post = HttpUtil.createPost(url);
+ post.contentType(ContentType.JSON.toString());
+ JSONObject params = new JSONObject();
params.put("key", "ru#0flkf3993qh!!rg!@y4)nhwi08c#tg_vasek!ja)kvfnfjyoljoz(@nai(jkf");
params.put("msisdn", toPhone);
params.put("message", msg);
params.put("sender_id", "I-GO");
- String s = httpClientUtil.pushHttpRequset("POST", url, params, null, "json");
- JSONObject jsonObject = JSON.parseObject(s);
+ System.err.println(params.toJSONString());
+ post.body(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(1701 == status){
+ if(null != status && 1701 == status){
return true;
}else{
+ System.err.println("短信发送失败:" + jsonObject.toJSONString());
return false;
}
}
-
-
-
- public static void main(String[] args) {
-// try {
-// SMSUtil.send_huawei_sms("b793ae3d41a049059197bfe92cf8bc83", "+233500666666", "[\"1234\"]");
-// } catch (Exception e) {
-// e.printStackTrace();
-// }
-
- // Find your Account SID and Auth Token at twilio.com/console
- // and set the environment variables. See http://twil.io/secure
-// String ACCOUNT_SID = "AC1fd05e898bd59d17ba72db621afca537";
-// String AUTH_TOKEN = "7cee1a6cb0e2936a9037be577b1ffe57";
-// try {
-// Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
-// Message message = Message.creator(
-// new PhoneNumber("+233570111999"),
-// new PhoneNumber("+16672740015"),
-// "This is the ship that made the Kessel Run in fourteen parsecs?"
-// ).create();
-// System.out.println(message.getSid() + "--->" + message.getStatus().toString());
-// }catch (Exception e){
-// e.printStackTrace();
-// }
-
-
-
+
+ public static void main(String[] ages){
+ SMSUtil smsUtil = new SMSUtil();
+ smsUtil.sendCellulantMessage("233244915521", "Votre code de validation est 123456 et il est valide pendant 5 minutes. Veuillez ne pas le révéler à d’autres personnes.");
}
}
--
Gitblit v1.7.1