From 9818ba3ab7cba1415d70d89273a4f203a2941c39 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Sat, 28 Jan 2023 14:21:29 +0800 Subject: [PATCH] =?UTF-8?q?:bug:=20#2921=20=E3=80=90=E5=B0=8F=E7=A8=8B?= =?UTF-8?q?=E5=BA=8F=E3=80=91=E4=BF=AE=E6=94=B9=E4=BD=BF=E7=94=A8okhttp?= =?UTF-8?q?=E5=8F=8Ajodd=E6=96=B9=E5=BC=8F=E8=AF=B7=E6=B1=82=E5=88=9B?= =?UTF-8?q?=E5=BB=BA=E7=9B=B4=E6=92=AD=E9=97=B4=E6=8E=A5=E5=8F=A3=E6=8A=A5?= =?UTF-8?q?=E9=94=99=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../util/http/jodd/JoddHttpSimplePostRequestExecutor.java | 2 +- .../util/http/okhttp/OkHttpSimplePostRequestExecutor.java | 2 +- .../wx/miniapp/api/impl/WxMaLiveServiceImplTest.java | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/jodd/JoddHttpSimplePostRequestExecutor.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/jodd/JoddHttpSimplePostRequestExecutor.java index a354eb4e06..654378271c 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/jodd/JoddHttpSimplePostRequestExecutor.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/jodd/JoddHttpSimplePostRequestExecutor.java @@ -4,7 +4,6 @@ import jodd.http.HttpRequest; import jodd.http.HttpResponse; import jodd.http.ProxyInfo; -import jodd.util.StringPool; import me.chanjar.weixin.common.enums.WxType; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.common.util.http.RequestHttp; @@ -35,6 +34,7 @@ public String execute(String uri, String postEntity, WxType wxType) throws WxErr } request.withConnectionProvider(provider); if (postEntity != null) { + request.contentType("application/json", "utf-8"); request.bodyText(postEntity); } HttpResponse response = request.send(); diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpSimplePostRequestExecutor.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpSimplePostRequestExecutor.java index 891907337f..a289f362e3 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpSimplePostRequestExecutor.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpSimplePostRequestExecutor.java @@ -24,7 +24,7 @@ public OkHttpSimplePostRequestExecutor(RequestHttp requestHttp) { @Override public String execute(String uri, String postEntity, WxType wxType) throws WxErrorException, IOException { - RequestBody body = RequestBody.Companion.create(postEntity, MediaType.parse("text/plain; charset=utf-8")); + RequestBody body = RequestBody.Companion.create(postEntity, MediaType.parse("application/json; charset=utf-8")); Request request = new Request.Builder().url(uri).post(body).build(); Response response = requestHttp.getRequestHttpClient().newCall(request).execute(); return this.handleResponse(wxType, Objects.requireNonNull(response.body()).string()); diff --git a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaLiveServiceImplTest.java b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaLiveServiceImplTest.java index 2f497935c7..9129b8e7fc 100644 --- a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaLiveServiceImplTest.java +++ b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaLiveServiceImplTest.java @@ -40,14 +40,14 @@ public void createRoom() throws Exception { roomInfo.setName("订阅通知直播间"); roomInfo.setCoverImg(mediaUpload.getMediaId()); Calendar c = Calendar.getInstance(); - c.set(2020, Calendar.DECEMBER, 10, 8, 0); + c.set(2023, Calendar.FEBRUARY, 10, 8, 0); roomInfo.setStartTime(c.getTimeInMillis() / 1000); - c.set(2020, Calendar.DECEMBER, 10, 12, 0); + c.set(2023, Calendar.FEBRUARY, 10, 12, 0); roomInfo.setEndTime(c.getTimeInMillis() / 1000); roomInfo.setAnchorName("鹏军_专业小程序开发"); roomInfo.setAnchorWechat("pengjun939961241"); - roomInfo.setCreaterWechat("pengjun939961241"); roomInfo.setShareImg(mediaUpload.getMediaId()); + roomInfo.setFeedsImg(mediaUpload.getMediaId()); roomInfo.setType(1); roomInfo.setScreenType(1); roomInfo.setCloseLike(0);