|
@@ -1,6 +1,10 @@
|
|
package com.caimei.modules.sys.utils;
|
|
package com.caimei.modules.sys.utils;
|
|
|
|
|
|
-import com.ruanwei.interfacej.SmsClientSend;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
|
+import com.thinkgem.jeesite.common.config.Global;
|
|
|
|
+import org.springframework.util.LinkedMultiValueMap;
|
|
|
|
+import org.springframework.util.MultiValueMap;
|
|
|
|
+import org.springframework.web.client.RestTemplate;
|
|
|
|
|
|
public class SMSUtils {
|
|
public class SMSUtils {
|
|
private static String url = "http://47.96.109.82:9999/sms.aspx";
|
|
private static String url = "http://47.96.109.82:9999/sms.aspx";
|
|
@@ -9,13 +13,30 @@ public class SMSUtils {
|
|
private static String password = "CaimeiSMS999";
|
|
private static String password = "CaimeiSMS999";
|
|
|
|
|
|
public static boolean sendSms(String mobile, String content){
|
|
public static boolean sendSms(String mobile, String content){
|
|
- String res = SmsClientSend.sendSms(url, userid, account, password, mobile, content);
|
|
|
|
- return res.indexOf("Success") != -1;
|
|
|
|
-// System.out.println("手机号:"+mobile +" - 内容:"+content);
|
|
|
|
-// return true;
|
|
|
|
|
|
+
|
|
|
|
+// String res = SmsClientSend.sendSms(url, userid, account, password, mobile, content);
|
|
|
|
+// return res.indexOf("Success") != -1;
|
|
|
|
+
|
|
|
|
+ // 获取core服务器地址
|
|
|
|
+ String coreServer = Global.getConfig("caimei.core");
|
|
|
|
+ RestTemplate restTemplate = new RestTemplate();
|
|
|
|
+ String uri = coreServer + "/tools/sms/send";
|
|
|
|
+ // 发起Post请求
|
|
|
|
+ MultiValueMap<String, String> paramMap = new LinkedMultiValueMap<>();
|
|
|
|
+ paramMap.add("mobile", mobile);
|
|
|
|
+ paramMap.add("content", content);
|
|
|
|
+ String result = restTemplate.postForObject(uri, paramMap, String.class);
|
|
|
|
+ System.out.println(result);
|
|
|
|
+ JSONObject json = (JSONObject) JSONObject.parse(result);
|
|
|
|
+ if (null != json && json.getInteger("code") == 0) {
|
|
|
|
+ return true;
|
|
|
|
+ } else {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
public static void main(String[] args) {
|
|
public static void main(String[] args) {
|
|
- System.out.println(sendSms("13631650502", "您登录亲朋棋牌的手机短 信验证码是:7895,祝您游戏愉快!请确认账号是由本人操作"));
|
|
|
|
|
|
+ //System.out.println(sendSms("13631650502", "您登录亲朋棋牌的手机短 信验证码是:7895,祝您游戏愉快!请确认账号是由本人操作"));
|
|
|
|
+ System.out.println(sendSms("15814011616", "您短信验证码是:7895"));
|
|
}
|
|
}
|
|
}
|
|
}
|