app/공중번호/애플릿 위챗 로그인 후 왜 유니언을 유일한 표식으로
2224 단어 위챗 로그인
유니언을 구체적으로 얻은 코드는 붙이지 않겠습니다.백엔드에서 얻을 수도 있고, 백엔드에서 얻은 후에 백엔드에 전달할 수도 있다.위챗 공식 문서는 비교적 분명하게 말한다.내가 흰둥이를 막을 테니 여기도 코드를 붙여라.
public Map getOpenidByCode1( String code,Integer type) {
initWxConfig(false);
Map parmas = new HashMap();
HttpClient client = new HttpClient();
String resultStr = null;
parmas.put("grant_type", "authorization_code");
if (type == 1) {//
parmas.put("appid", APPID_X);
parmas.put("secret", APPSECRET_X);
parmas.put("js_code", code);
resultStr = client.get("https://api.weixin.qq.com/sns/jscode2session", parmas);
}
if (type == 2) {//
parmas.put("appid", APPID_G);
parmas.put("secret", APPSECRET_G);
parmas.put("code", code);
resultStr = client.get("https://api.weixin.qq.com/sns/oauth2/access_token", parmas);
}
JSONObject result = JSONObject.parseObject(resultStr);
checkErr(result);
Map body = new HashMap();
String openid = result.getString("openid");
String unionid = result.getString("unionid");
body.put("openId", openid);
body.put("unionid",unionid );
System.out.println(unionid);
return body;
}
private void checkErr(JSONObject result) {
if(result == null){
return ;
}
String errcode = result.getString("errcode");
if (StringUtils.isEmpty(errcode)) {
return;
}
if ("0".equals(errcode)) {
return;
}
if ("40014".equals(errcode) || "42001".equals(errcode) ) {
/**/if (lock.tryLock()) {
try {
token();
} finally {
lock.unlock();
}
}
}
throw new BizException(Code.ERR_CODE);
}
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
app/공중번호/애플릿 위챗 로그인 후 왜 유니언을 유일한 표식으로앱/공중번호/애플릿 위챗 로그인 후 왜 유니언을 유일한 표식으로 사용해야 하는지, 3단 위챗 오픈id가 일치하지 않아 위챗이 3단 로그인 후 3명의 사용자가 생성됩니다.삼단은 위챗 오픈 플랫폼에서 서로 연결된 후에 ...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.