forked from chanjarster/weixin-java-tools
-
-
Notifications
You must be signed in to change notification settings - Fork 8.5k
MP_http代理支持
Binary Wang edited this page Aug 8, 2018
·
3 revisions
在某些环境下,应用程序必须通过代理才能够访问微信接口,比如阿里的ACE(ACE线上环境不能直接访问外网。 HTTP请求需要通过使用代理: http://ace.aliapp.com/java/quick-start.md?spm=5176.383729.9.2.6HqPoT&file=quick-start.md )。
你可以在构造自己的WxMpConfigStorage
的时候设置http代理信息:
- httpPoxyHost
- httpProxyPort
- httpProxyUsername(可选)
- httpProxyPassword(可选)
只要你设置了http代理,那么所有的请求都会从代理走。
String encType = request.getParameter("encrypt_type");
String nonce = request.getParameter("nonce");
String timestamp = request.getParameter("timestamp");
String msgSignature = request.getParameter("msg_signature");
String signature = request.getParameter("signature");
String openid = request.getParameter("openid");
log.info("接收微信请求:[openid=[{}], [openid=[{}],[signature=[{}], encType=[{}], msgSignature=[{}],"
+ " timestamp=[{}], nonce=[{}], requestBody=[{}] ",
appid, openid, signature, encType, msgSignature, timestamp, nonce, requestBody);
if (!this.wxMpService.switchover(appid)) {
throw new IllegalArgumentException(String.format("未找到对应appid=[%s]的配置,请核实!", appid));
}
if (!wxMpService.checkSignature(timestamp, nonce, signature)) {
throw new IllegalArgumentException("非法请求,可能属于伪造的请求!");
}
return ResponseEntity.ok("");