When the user clicks on the application to jump to the URL we set, it does not actually bring any user information. In order to obtain user information, we need to use the OAuth2.0 interface provided by WeChat.
Obtaining user information is divided into two steps:
Construct the URL to obtain the code
Obtain member information according to the code
1. Construct the URL to obtain the code
If an enterprise requires employees to bring their identity information when jumping to the corporate webpage, the following link must be constructed:
https://open.weixin.qq.com/connect/oauth2/authorize?appid=CORPID&redirect_uri=REDIRECT_URI&response_type=code&scope=SCOPE&state=STATE#wechat_redirect
Parameter Description
Parameters | Must | Description |
---|---|---|
appid | is the CorpID## of the | enterprise |
is the callback link address redirected after | authorization. Please use urlencode to process the link | |
is the return type of | , which is fixed at this time: code | |
is | Application authorization scope, fixed at this time: snsapi_base | |
No | The state parameter will be included after redirection, and the enterprise can fill it in The parameter value of a-zA-Z0-9, the length cannot exceed 128 bytes | |
Yes | WeChat terminal uses this parameter Determine whether identity information needs to be brought |
must | Description | |
---|---|---|
is | Call interface certificate | |
is the code obtained by | through member authorization. The code brought by member authorization will be different each time. The code can only be used once and will automatically expire if not used for 10 minutes |
{ "UserId":"USERID", "DeviceId":"DEVICEID" }
<br>
The above is the detailed content of Introduction to WeChat enterprise account development to obtain user information. For more information, please follow other related articles on the PHP Chinese website!