| | |
| | | * @return |
| | | */ |
| | | public Map<String, Object> code2Session(String jscode) throws Exception{ |
| | | System.err.println("看看调用奥"); |
| | | System.err.println("jsCode"+"========="+jscode); |
| | | String url = "https://api.weixin.qq.com/sns/jscode2session?appid=" + wxAppletsAppid + "&secret=" + wxAppletsAppSecret |
| | | + "&js_code=" + jscode + "&grant_type=authorization_code"; |
| | | HttpResult httpResult = httpClientUtil.pushHttpRequset("GET", url, null, null, "form"); |
| | |
| | | return null; |
| | | } |
| | | JSONObject jsonObject = JSON.parseObject(httpResult.getData()); |
| | | System.err.println("返回json串"+jsonObject); |
| | | int errcode = jsonObject.getIntValue("errcode"); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("errcode", errcode); |
| | | System.err.println("返回code"+errcode); |
| | | if(errcode == 0){//成功 |
| | | map.put("openid", jsonObject.getString("openid")); |
| | | map.put("sessionKey", jsonObject.getString("session_key")); |