Skip to content

Commit

Permalink
🐛 #2921 【小程序】修改使用okhttp及jodd方式请求创建直播间接口报错的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
sojasosse authored and binarywang committed Jan 28, 2023
1 parent 89343a1 commit fbcfd44
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit fbcfd44

Please sign in to comment.