Turn: [No.] public micro-channel micro-channel snsapi_base silent authorized to implement authorization and snsapi_userinfo pages (not recommended silence, the direct use of the initiative is more convenient)

Disclaimer: This article is the original article CSDN bloggers "Xiao Lu Ge", following the CC 4.0 by-sa copyright agreement, reproduced, please attach the original source link and this statement.

Original link: https: //blog.csdn.net/qq_37462176/article/details/78917339

 

1, snsapi_base only get access_token and openID, finish the process is terminated

2, snsapi_userinfo user can obtain more detailed information, such as Avatar, nickname, gender, etc.

(Note: the time when the scope = snsapi_userinfo; develop micro-channel reference document: https: //mp.weixin.qq.com/wiki t = resource / res_main & id = mp1421140842?)

/ * Get a global access_token openid and personal information: * / 

$ URL = "https://api.weixin.qq.com/cgi-bin/user/info?access_token= { $ access_token } = {& openid $ openid } & lang = zh_CN "

 

When scope = snsapi_base;

1, the first step, access code,

https://open.weixin.qq.com/connect/oauth2/authorize?appid='.APPID.'&redirect_uri='.urldecode(URL).'login.php&response_type=code&scope=snsapi_base&state=start#wechat_redirect
2, a second step, get openID , web authorization access_token (Note: authorized difference access_token pages of ordinary access_token)

https://api.weixin.qq.com/sns/oauth2/access_token?appid='.APPID.'&secret='.APPSECRET.'&code='.CODE.'&grant_type=authorization_code
3, the third step, to obtain general access_token , valid for 7200 seconds
https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=$appid&secret=$secret
. 4, a fourth step of binding openID and general access_token obtaining user details, https: //api.weixin.qq.com/cgi-bin/user/info?access_token='.$access_token.'&openid='.$openId.'&lang=zh_CN

 

Guess you like

Origin www.cnblogs.com/xuzhengzong/p/11410596.html