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

在项目使用中发现2处bug,修正提交 #380

Closed
wants to merge 2 commits into from
Closed
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 @@ -163,7 +163,10 @@ public void run() {
})
);
} else {
res = rule.service(wxMessage, context, this.wxMpService, this.sessionManager, this.exceptionHandler);
WxMpXmlOutMessage temp = rule.service(wxMessage, context, this.wxMpService, this.sessionManager, this.exceptionHandler);
if(temp != null){
res = temp;
}
// 在同步操作结束,session访问结束
this.log.debug("End session access: async=false, sessionId={}", wxMessage.getFromUser());
sessionEndAccess(wxMessage);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import me.chanjar.weixin.common.exception.WxErrorException;
import me.chanjar.weixin.common.util.http.RequestHttp;
import me.chanjar.weixin.common.util.http.okhttp.OkHttpProxyInfo;
import me.chanjar.weixin.common.util.json.WxGsonBuilder;
import me.chanjar.weixin.mp.bean.material.WxMpMaterialNews;
import me.chanjar.weixin.mp.util.http.MaterialNewsInfoRequestExecutor;
import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder;
Expand All @@ -12,11 +13,15 @@
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

/**
* Created by ecoolper on 2017/5/5.
*/
public class OkhttpMaterialNewsInfoRequestExecutor extends MaterialNewsInfoRequestExecutor<OkHttpClient, OkHttpProxyInfo> {
private static final MediaType JSON = MediaType.parse("application/json");

private final Logger logger = LoggerFactory.getLogger(this.getClass());
public OkhttpMaterialNewsInfoRequestExecutor(RequestHttp requestHttp) {
super(requestHttp);
Expand All @@ -28,9 +33,10 @@ public WxMpMaterialNews execute(String uri, String materialId) throws WxErrorExc
//得到httpClient
OkHttpClient client = requestHttp.getRequestHttpClient();

RequestBody requestBody = new FormBody.Builder().add("media_id", materialId).build();
Map<String, String> params = new HashMap<>();
params.put("media_id", materialId);
RequestBody requestBody = RequestBody.create(JSON, WxGsonBuilder.create().toJson(params));
Request request = new Request.Builder().url(uri).post(requestBody).build();

Response response = client.newCall(request).execute();
String responseContent = response.body().string();
this.logger.debug("响应原始数据:{}", responseContent);
Expand Down