Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【小程序】修改使用okhttp及jodd创建直播间报错问题 #2921

Merged
merged 1 commit into from
Jan 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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