# Get authorized user information
Interface should be called on the server side, not in the front end (Weixin Mini Program, web pages, APP, etc.) directly called, specific reference interface call guide
Interface English name: snsUserInfo
If the web page authorization scope is snsapi_userinfo, then the developer can pull user information through access_token and openid.
Note: The frequency limit for this interface is 50,000 / min
# 1. How to call
# HTTPS calls
GET https://api.weixin.qq.com/sns/userinfo?access_token=ACCESS_TOKEN&openid=OPENID&lang=LANG
# Cloud Calls
- This interface does not support cloud calls
# Third party invocation
- Third Party Platform calls are not supported by this interface.
# 2. Request parameters
# Query parametersQuery String parameters
Parameter Name | type | Required to fill in | Example | Introductions |
---|---|---|---|---|
access_token | string | yes | - | Interface invoke credentials, using access_token |
openid | string | yes | - | The unique identifier of the user |
lang | string | no | zh_CN | Back to country language version, zh_CN simplified, zh_TW traditional, en English |
# Request BodyRequest Payload
nothing
# 3. Return Parameters
# Response Payload
Parameter Name | type | Introductions |
---|---|---|
openid | string | The unique identifier of the user |
nickname | string | User nickname |
sex | number | User's gender, a value of 1 is male, avalue of 2 is female, and a value 0 is unknown |
headimgurl | string | User avatar. The last value represents the square avatar size (there are values 0, 46, 64, 96, 132, and 0 represents a 640 * 640 square avatar). This item is empty when the user does not have a avatar.If the user changes the avatar, the original avatar URL will become invalid. |
unionid | string | This field appears only after the user has bound Official Account to WeChat open platform account. |
province | string | Provinces in which the user's profile was filled |
city | string | Cities populated by the average user's profile |
country | string | Countries, such as China for CN |
privilege | array | User privilege information, json array, such as WeChat |
# 4. Note
There are no special considerations for this interface
# 5. Code examples
Example Requests
https://api.weixin.qq.com/sns/userinfo?access_token=ACCESS_TOKEN&openid=OPENID&lang=zh_CN
Return an example
{
"openid": "OPENID",
"nickname": NICKNAME,
"sex": 1,
"province":"PROVINCE",
"city":"CITY",
"country":"COUNTRY",
"headimgurl":"https://thirdwx.qlogo.cn/mmopen/g3MonUZtNHkdmzicIlibx6iaFqAc56vxLSUfpb6n5WKSYVY0ChQKkiaJSgQ1dZuTOgvLLrhJbERQQ4eMsv84eavHiaiceqxibJxCfHe/46",
"privilege":[ "PRIVILEGE1" "PRIVILEGE2" ],
"unionid": "o6_bmasdasdsad6_2sgVt7hMZOPfL"
}
# 6. Error code
The following is a list of error codes for this interface, other error codes can refer to General error codes
Error code | Error Description | Solutions |
---|---|---|
40003 | invalid openid | Invalid OpenID. Please confirm if the OpenID is following Official Account, or if it is another OpenID from the Official Account message template. |
# 7. Scope of application
How this interface can be invoked under different account types:
Service Account | Mobile App | Website App |
---|---|---|
Certification only | ✔ | ✔ |
- Authentication only: means that only authenticated accounts are allowed to be invoked by the enterprise entity, and accounts that are not authenticated or do not support authentication cannot be invoked.
- ✔: The account can call this interface
- Other account types that are not expressly stated may not be called on this interface without special instructions;