小程序后台通过wx.login()返回的code取session时直接返回40029
private String code2Session(String jsCode) {
StringBuilder urlPath = new StringBuilder("https://api.weixin.qq.com/sns/jscode2session");
urlPath.append(String.format("?appid=%s", SecurityConstants.WXAPPLET_APPID));
urlPath.append(String.format("&secret=%s", SecurityConstants.WXAPPLET_APPSECRET));
urlPath.append(String.format("&js_code=%s", jsCode));
urlPath.append(String.format("&grant_type=%s", "authorization_code")); // 固定值
return HTTPClientUtils.doGet(urlPath.toString());
}
小程序code: 051v0m000ObAyK19vV1005SDWf0v0m0s