java根据小程序code获取用户openId
java根据小程序code获取用户openId
String result = HttpRequest.sendGet("https://api.weixin.qq.com/sns/jscode2session",
"appid=" + FgStaticParam.AppId + //小程序APPID
"&secret="+ CloudSignHelper.wxspSecret + //小程序秘钥
"&js_code="+ registerReq.getCode() + //前端传来的code
"&grant_type=authorization_code");
JSONObject jsonObject = JSONObject.parseObject(result);
if (jsonObject.containsKey("errcode")) {
throw new FdServiceException(ErrorCode.QUERY_EXCEPTION, "code无效");
}
String openId