调用 wxMaService.jsCode2SessionInfo(code)报错
简要描述
调用 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)
提示信息里说的也挺清楚的吧,你的请求里的js_code有问题,存在非法字符
是的,code中含有特殊字符,所以
String result = get(JSCODE_TO_SESSION_URL, Joiner.on("&").withKeyValueSeparator("=").join(params));
这段代码是不是要处理下,把参数encode一下,或者我自己encode下code
你可以尝试下,如果测试有效果,可以直接提交PR代码上来
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.