Describes the implementation of snsapi_base, snsapi_userinfo, and silent authorization in the development process.
Implementation of snsapi_base, snsapi_userinfo and silent authorization in development
Snsapi_base and snsapi_userinfo are two scopes for Obtaining user information through webpage authorization.
Snsapi_base can only obtain access_token and openID
Snsapi_userinfo can be used to obtain more detailed user information, such as profile pictures, nicknames, and gender.
First, the access_token here is different from the basic access_token (for example, used in a custom menu. The differences are as follows:
The webpage-authorized access_token is updated together each time the openID is obtained. The interface call frequency limit is "unlimited"
The basic access_token is generally limited to 2000 times/day. You need to save it and update it regularly.
Second, when the scope is snsapi_userinfo, according to the instructions in the official documentation, the user needs to click authorization. However, I found that there is a way to obtain it silently without clicking authorization. The method is as follows:
1. Use snsapi_base to obtain both access_token and openid
2. Use access_token and openid here for the https://api.weixin.qq.com/sns/userinfo? Access_token = ACCESS_TOKEN & openid = OPENID & lang = zh_CN
3. After the request is successful, the user details are obtained silently.
The premise of the above method is that the user pays attention to the same public account. If you borrow other public accounts, you need to click authorize.
Thank you for reading this article. I hope it will help you. Thank you for your support for this site!