WxJava icon indicating copy to clipboard operation
WxJava copied to clipboard

调用 wxMaService.jsCode2SessionInfo(code)报错

Open listen-lee opened this issue 3 years ago • 4 comments

简要描述

调用 WxMaJscode2SessionResult wxMaJscode2SessionResult = wxMaService.jsCode2SessionInfo(code); 报错

模块版本情况

  • WxJava 模块名: weixin-java-miniapp
  • WxJava 版本号: 4.4.0

详细描述

WxMaJscode2SessionResult wxMaJscode2SessionResult = wxMaService.jsCode2SessionInfo(code);

日志

java.lang.IllegalArgumentException: Illegal character in query at index 252: https://api.weixin.qq.com/sns/jscode2session?access_token=64_KsEryC1vMeDhGzSgtsuty7N_-iZdLe3KzTo0QDvl-P2g1TbQMMO_YrK-Mvox-Gafy9XJPav2i_UaQkBlrrMggOwOlnl7_fUKYV5mRk8DTqA1R-bwjasBtqOLGdoXGTfAFARAN&js_code=0318iH0w3Vw1XZ2Bhy1w30oVb108iH04%bf%27%bf'%27%22'"\\%5C%0d%0a%23#&secret=123&grant_type=authorization_code&appid=123
    at java.base/java.net.URI.create(URI.java:883)
    at org.apache.http.client.methods.HttpGet.<init>(HttpGet.java:66)

listen-lee avatar Jan 17 '23 09:01 listen-lee

提示信息里说的也挺清楚的吧,你的请求里的js_code有问题,存在非法字符

binarywang avatar Jan 28 '23 06:01 binarywang

是的,code中含有特殊字符,所以 String result = get(JSCODE_TO_SESSION_URL, Joiner.on("&").withKeyValueSeparator("=").join(params)); 这段代码是不是要处理下,把参数encode一下,或者我自己encode下code

listen-lee avatar Feb 20 '23 00:02 listen-lee

你可以尝试下,如果测试有效果,可以直接提交PR代码上来

binarywang avatar Feb 20 '23 04:02 binarywang

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Apr 21 '23 21:04 stale[bot]