소스 검색

微信登录

he2802 4 년 전
부모
커밋
0e65becafd
1개의 변경된 파일5개의 추가작업 그리고 4개의 파일을 삭제
  1. 5 4
      zhongzheng-framework/src/main/java/com/zhongzheng/framework/web/service/WxLoginService.java

+ 5 - 4
zhongzheng-framework/src/main/java/com/zhongzheng/framework/web/service/WxLoginService.java

@@ -108,12 +108,13 @@ public class WxLoginService
         String param = String.format(wxAuthParam, appid, appsrcret, loginBody.getCode());
         String resultString  = HttpUtils.sendGet(wxAuthUrl,param);
         //解析json
-        JSONObject jsonObject1 = (JSONObject) JSONObject.parse(resultString);
-        String session_key = jsonObject1.get("session_key")+"";
-        String openid = jsonObject1.get("openid")+"";
+        JSONObject jsonObject = (JSONObject) JSONObject.parse(resultString);
+        String session_key = String.valueOf(jsonObject.get("session_key"));
+        String openId = String.valueOf(jsonObject.get("openid"));
+        String unionId = String.valueOf(jsonObject.get("unionid"));
     //    WxLoginResultBo wxLoginResult = restTemplate.getForObject(url, WxLoginResultBo.class);
         String wxResult = obtainWxPhone(loginBody.getIv(),loginBody.getEncryptedData(),session_key);
-        return resultString;
+        return wxResult;
     }
 
     public String obtainWxPhone(String iv, String encryptedData,String session_key){