Bladeren bron

短信发送模板

zhaopeiqing 3 jaren geleden
bovenliggende
commit
94948be388

+ 1 - 1
src/main/java/com/ssm/controller/business/SendMessageContorller.java

@@ -224,7 +224,7 @@ public class SendMessageContorller {
 			request.setCharacterEncoding("utf-8");
 			String smsUserPhones = request.getParameter("phones");
 			String content = request.getParameter("contents");
-			String templateId = request.getParameter("templateId");
+			Integer templateId = Integer.parseInt(request.getParameter("templateId").toString());
 			String res = SmsUtil.sendTemplateSmsPost(smsUserPhones, content, templateId);
 			Map mapObj = JSON.parseObject(res, Map.class);
 			String msgNo = mapObj.get("msg_no").toString();

+ 2 - 2
src/main/java/com/ssm/util/sms/SmsUtil.java

@@ -123,14 +123,14 @@ public class SmsUtil {
 	 * @param templateId 模板id
 	 * @return res    json返回值
 	 */
-	public static String sendTemplateSmsPost(String phones, String content, String templateId) throws IOException {
+	public static String sendTemplateSmsPost(String phones, String content, Integer templateId) throws IOException {
 		HttpClient httpClient = HttpClients.createDefault();
 		HttpPost httpPost = new HttpPost("https://api.4321.sh/sms/template");
 		httpPost.addHeader("Content-Type", "application/json");
 		Map<String, Object> map = new HashMap<>();
 		map.put("apikey", "N11727b332");// api接口账号
 		map.put("secret", "1172799e3242ebe1");// api接口秘钥
-		map.put("sign_id", "101760");// 签名id
+		map.put("sign_id", 101760);// 签名id
 		map.put("template_id", templateId);// 模板id
 		map.put("mobile", phones);// 手机号
 		map.put("content", content);// 短信内容