记得上下班打卡 | git大法好,push需谨慎

Commit f44d2da5 authored by 张国柄's avatar 张国柄

fix:get openid;

parent 0bee2ceb
......@@ -335,11 +335,11 @@ public class AdamLoginController {
@ApiOperation(value = "微信小程序登录凭证校验", notes = "这里仅用于获取OPENID使用。登录凭证校验。通过 wx.login 接口获得临时登录凭证 code 后传到开发者服务器调用此接口完成登录流程。更多使用方法详见 https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/login/auth.code2Session.html")
@GetMapping(value = {"wxa/code2session"})
public ResponseDto<String> wxaCode2Session(@RequestParam String jsCode) {
String openId = null;
String openId = null, respJStr = null;
try {
String url = AdamWechatConst.API_URL_JS_CODE2SESSION.replace("APPID", AdamWechatConst.zhengzaiAppletAppid)
.replace("SECRET", AdamWechatConst.zhengzaiAppletSecret).replace("JSCODE", jsCode);
String respJStr = HttpUtil.get(url, null);
respJStr = HttpUtil.get(url, null);
JsonNode respJNode = JsonUtils.fromJson(respJStr, JsonNode.class);
if (null == respJNode || !"0".equalsIgnoreCase(respJNode.get("errcode").asText())) {
log.warn("WX.API调用失败[{}]", respJStr);
......@@ -347,7 +347,7 @@ public class AdamLoginController {
}
openId = respJNode.get("openid").asText();
} catch (Exception e) {
log.error("WX.API调用异常[jsCode:{}]", jsCode, e);
log.error("WX.API调用异常[jsCode:{},respJStr={}]", jsCode, respJStr, e);
}
return ResponseDto.success(openId);
}
......@@ -356,11 +356,11 @@ public class AdamLoginController {
@ApiOperation(value = "微信网站应用登录", notes = "这里仅用于获取OPENID使用。方法详见 https://developers.weixin.qq.com/doc/oplatform/Website_App/WeChat_Login/Wechat_Login.html")
@GetMapping(value = {"wx/oauth2/access_token"})
public ResponseDto<String> wxOauth2AccessToken(@RequestParam String code) {
String openId = null;
String openId = null, respJStr = null;
try {
String url = AdamWechatConst.API_URL_OAUTH2_ACCESS_TOKEN.replace("APPID", AdamWechatConst.zhengzaiServiceAppid)
.replace("SECRET", AdamWechatConst.zhengzaiServiceSecret).replace("CODE", code);
String respJStr = HttpUtil.get(url, null);
respJStr = HttpUtil.get(url, null);
JsonNode respJNode = JsonUtils.fromJson(respJStr, JsonNode.class);
if (null == respJNode || !"0".equalsIgnoreCase(respJNode.get("errcode").asText())) {
log.warn("WX.API调用失败[{}]", respJStr);
......@@ -368,7 +368,7 @@ public class AdamLoginController {
}
openId = respJNode.get("openid").asText();
} catch (Exception e) {
log.error("WX.API调用异常[code:{}]", code, e);
log.error("WX.API调用异常[jsCode:{},respJStr={}]", code, respJStr, e);
}
return ResponseDto.success(openId);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment