From 7e339af9f08a26fb0ffa777148a5d66a8243cc37 Mon Sep 17 00:00:00 2001 From: = <=> Date: Wed, 26 May 2021 01:06:23 +0800 Subject: [PATCH] =?UTF-8?q?'=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/cweb/controller/SmsContentController.java | 8 ++++---- .../src/main/java/com/hai/common/utils/HttpsUtils.java | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/hai-cweb/src/main/java/com/cweb/controller/SmsContentController.java b/hai-cweb/src/main/java/com/cweb/controller/SmsContentController.java index ce8c0f35..4a639c48 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/SmsContentController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/SmsContentController.java @@ -50,8 +50,7 @@ public class SmsContentController { list.add(phone); map.put("signature", "嗨森逛"); - String param = "88200409698&to" + phone + "&templateId=f42261f78d54488391f1d1ac4bd5bd3f&statusCallback=[" + phone +"]&signature=嗨森逛"; - + String param = "88200409698&to="+phone+"&templateId=f42261f78d54488391f1d1ac4bd5bd3f&templateParas=[\"" + 123456 +"\"]"; //JSON.toJSONString(map); Map body = new LinkedHashMap<>(); body.put("from", param); @@ -59,8 +58,9 @@ public class SmsContentController { String nonce = UUID.randomUUID().toString(); String created = DateUtil.date2String(new Date(), "yyyy-MM-dd'T'HH:mm:ss'Z'"); - - String passwordDigest = Base64Util.encode(encodeBySHA256(nonce + created + "9CWFv4NlaRX49n43VPA6eucZ8xeQ")); + System.out.println(encodeBySHA256(nonce + created + "9CWFv4NlaRX49n43VPA6eucZ8xeQ")); + System.out.println(Base64Util.encode(encodeBySHA256(nonce + created + "9CWFv4NlaRX49n43VPA6eucZ8xeQ"))); + String passwordDigest = Base64Util.encode(encodeBySHA256(nonce + created + "9CWFv4NlaRX49n43VPA6eucZ8xeQ")) + "=="; // 9CWFv4NlaRX49n43VPA6eucZ8xeQ Map header = new LinkedHashMap<>(); diff --git a/hai-service/src/main/java/com/hai/common/utils/HttpsUtils.java b/hai-service/src/main/java/com/hai/common/utils/HttpsUtils.java index 742381ca..157055e0 100644 --- a/hai-service/src/main/java/com/hai/common/utils/HttpsUtils.java +++ b/hai-service/src/main/java/com/hai/common/utils/HttpsUtils.java @@ -3,6 +3,7 @@ package com.hai.common.utils; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; +import com.hai.common.pay.util.IOUtil; import org.apache.commons.io.IOUtils; import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; @@ -315,7 +316,7 @@ public class HttpsUtils { for (Map.Entry entry : header.entrySet()) { httpPost.setHeader(entry.getKey(), entry.getValue().toString()); } - StringEntity stringEntity = new StringEntity(JSON.toJSONString(body), "UTF-8");// 解决中文乱码问题 + StringEntity stringEntity = new StringEntity(IOUtil.urlEncode("from=" +body.get("from").toString(), "UTF-8"));// 解决中文乱码问题 stringEntity.setContentEncoding("UTF-8"); stringEntity.setContentType("application/x-www-form-urlencoded"); httpPost.setEntity(stringEntity);