更改短信发送地址
This commit is contained in:
parent
21b24fdf93
commit
b8d6b98faf
@ -4,6 +4,7 @@ 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;
|
||||
@ -11,7 +12,6 @@ import org.apache.http.entity.StringEntity;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClients;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@ -23,12 +23,12 @@ import java.util.UUID;
|
||||
* 崔宝铖 2023年5月12日11:28:11
|
||||
*/
|
||||
public class TenlionSMS {
|
||||
|
||||
private static String smsKey = "c7bbe767-dad7-413b-a9f7-3d49d556366c";
|
||||
|
||||
private static String smsSecret = "zinF7QrbMmg72CyahEReu6vZJ4L9j1HB";
|
||||
private static String smsKey = "73bd027a-b9f0-44ac-a414-984baf23f988";
|
||||
|
||||
private static String systemUrl = "http://192.168.0.115:8099/operator-plugin";
|
||||
private static String smsSecret = "BMAF4tiD+QoB1rK7AMC4nuRWISbf83Tc";
|
||||
|
||||
private static String systemUrl = "";
|
||||
// 短信发送地址
|
||||
private static String sendSMSUrl = systemUrl + "/app/send";
|
||||
// 短信状态查询地址
|
||||
@ -44,27 +44,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(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(getMessageReply(uuid, "17691030315"));
|
||||
// 短信状态查询
|
||||
// System.out.println(getMessageStatus("26800e6c-004a-4d77-bac2-3f80c70a423d", "17691030315"));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取模板列表
|
||||
* @return
|
||||
@ -87,7 +91,7 @@ public class TenlionSMS {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 短信回复查询
|
||||
* @param smsNO 36位UUID
|
||||
@ -112,7 +116,7 @@ public class TenlionSMS {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 短信状态查询
|
||||
* @param smsNO 36位UUID
|
||||
@ -138,7 +142,7 @@ public class TenlionSMS {
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 短信发送
|
||||
* @param smsNO 36位UUID
|
||||
@ -153,7 +157,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();
|
||||
@ -170,7 +174,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();
|
||||
|
Loading…
Reference in New Issue
Block a user