Commit 182e9541 authored by 廖旭伟's avatar 廖旭伟

获取微信openId接口

parent 4c245d0b
......@@ -59,14 +59,14 @@ public class H5LoginController extends BaseCRUDJsonBodyMappingController<UserSer
/**
* 微信appId
*/
@Value("${WeChat.pc.appID:wx3490570828df45c8}")
private static String APP_ID;
@Value("${WeChat.pc.appID}")
private String APP_ID;
/**
* 微信appSecret
*/
@Value("${WeChat.pc.appSecret:8654c409f1a18f7ddffc70ee20d05ef1}")
private static String APP_SECRET;
@Value("${WeChat.pc.appSecret}")
private String APP_SECRET;
@RequestMapping(value = {"bind"},method = {RequestMethod.POST, RequestMethod.GET})
@UnAuth
......@@ -83,6 +83,12 @@ public class H5LoginController extends BaseCRUDJsonBodyMappingController<UserSer
Map<String,String> accessTokenMap = WeChatUtils.getAccessToken(loginCode,APP_ID,APP_SECRET);
//String access_token = accessTokenMap.get("access_token");//接口调用凭证,登录后右上角展示数据需要该值去获取
String openid = accessTokenMap.get("openid");//授权用户唯一标识
if(StringUtils.isEmpty(openid)){
log.error("bind error ", accessTokenMap.get("errmsg"));
ret.put(KEY_RESULT_CODE, VALUE_RESULT_FAILURE);
ret.put(KEY_RESULT_MSG, accessTokenMap.get("errmsg"));
return ret.toJSONString();
}
data.put("openId", openid);
ret.put(KEY_RESULT_DATA, data);
ret.put(KEY_RESULT_CODE, VALUE_RESULT_SUCCESS);
......
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