8000 :bug: #2921 【小程序】修改使用okhttp及jodd方式请求创建直播间接口报错的问题 · binarywang/WxJava@fbcfd44 · GitHub
[go: up one dir, main page]

Skip to content

Commit fbcfd44

Browse files
sojasossebinarywang
authored andcommitted
🐛 #2921 【小程序】修改使用okhttp及jodd方式请求创建直播间接口报错的问题
1 parent 89343a1 commit fbcfd44

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/jodd/JoddHttpSimplePostRequestExecutor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import jodd.http.HttpRequest;
55
import jodd.http.HttpResponse;
66
import jodd.http.ProxyInfo;
7-
import jodd.util.StringPool;
87
import me.chanjar.weixin.common.enums.WxType;
98
import me.chanjar.weixin.common.error.WxErrorException;
109
import me.chanjar.weixin.common.util.http.RequestHttp;
@@ -35,6 +34,7 @@ public String execute(String uri, String postEntity, WxType wxType) throws WxErr
3534
}
3635
request.withConnectionProvider(provider);
3736
if (postEntity != null) {
37+
request.contentType("application/json", "utf-8");
3838
request.bodyText(postEntity);
3939
}
4040
HttpResponse response = request.send();

weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpSimplePostRequestExecutor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public OkHttpSimplePostRequestExecutor(RequestHttp requestHttp) {
2424

2525
@Override
2626
public String execute(String uri, String postEntity, WxType wxType) throws WxErrorException, IOException {
27-
RequestBody body = RequestBody.Companion.create(postEntity, MediaType.parse("text/plain; charset=utf-8"));
27+
RequestBody body = RequestBody.Companion.create(postEntity, MediaType.parse("application/json; charset=utf-8"));
2828
Request request = new Request.Builder().url(uri).post(body).build();
2929
Response response = requestHttp.getRequestHttpClient().newCall(request).execute();
3030
return this.handleResponse(wxType, Objects.requireNonNull(response.body()).string());

weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaLiveServiceImplTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,14 @@ public void createRoom() throws Exception {
4040
roomInfo.setName("订阅通知直播间");
4141
roomInfo.setCoverImg(mediaUpload.getMediaId());
4242
Calendar c = Calendar.getInstance();
43-
c.set(2020, Calendar.DECEMBER, 10, 8, 0);
43+
c.set(2023, Calendar.FEBRUARY, 10, 8, 0);
4444
roomInfo.setStartTime(c.getTimeInMillis() / 1000);
45-
c.set(2020, Calendar.DECEMBER, 10, 12, 0);
45+
c.set(2023, Calendar.FEBRUARY, 10, 12, 0);
4646
roomInfo.setEndTime(c.getTimeInMillis() / 1000);
4747
roomInfo.setAnchorName("鹏军_专业小程序开发");
4848
roomInfo.setAnchorWechat("pengjun939961241");
49-
roomInfo.setCreaterWechat("pengjun939961241");
5049
roomInfo.setShareImg(mediaUpload.getMediaId());
50+
roomInfo.setFeedsImg(mediaUpload.getMediaId());
5151
roomInfo.setType(1);
5252
roomInfo.setScreenType(1);
5353
roomInfo.setCloseLike(0);

0 commit comments

Comments
 (0)
0