# Get basic user information

Debugging Tools

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: userInfo

After a follower interacts with Official Account, the Official Account message template can obtain the follower's OpenID (encrypted WeChat number), which is unique for each user.For different Official Account message templates, the same user has different openids.

Through this interface, basic user information including language and attention time can be obtained according to OpenID.

# 1. How to call

# HTTPS calls

GET https://api.weixin.qq.com/cgi-bin/user/info?access_token=ACCESS_TOKEN&openid=OPENID&lang=LANG

# Cloud Calls

  • Call method: officialAccount.user.getInfo

  • The input and exit parameters are the same as the HTTPS call, which can be called in the cloud call documentation

# Third party invocation

  • This interface supports Third Party Platform generation business call.

  • The permission set id to which the interface belongs is: 2,100

  • When a service provider is authorized by one of the permissions set, it can call on behalf of the merchant by using authorizer_access_token , which can be viewed in the third-party call documentation.

# 2. Request parameters

# Query parametersQuery String parameters

Parameter NametypeRequired to fill inExampleIntroductions
access_tokenstringyesACCESS_TOKENInterface invocation credentials, using access_token , authorizer_access_token
openidstringyeso6_bmjrPTlm6_2sgVt7hMZOPfL2MThe identity of the normal user, unique to the current Official Account
langstringnozh_CNBack to national regional language version

# Request BodyRequest Payload

nothing

# 3. Return Parameters

# Response Payload

Parameter NametypeIntroductions
subscribenumberIf the user subscribes to the Official Account ID, a value of 0 means that the user does not follow the Official Account message template and cannot pull the rest of the message.
openidstringUser's ID, unique to the current Official Account
languagestringUser's language, simplified Chinese for zh_CN
subscribe_timetimestampUsers pay attention to the time, which is a time stamp. If the user has followed it several times, then the last followed time is taken
unionidstringThis field appears only after the user has bound Official Account to WeChat open platform account.
remarkstringOfficial Account The Official Account message template can be added by WeChat Official Account message.
groupidnumberThe user's group ID (compatible with the old user group interface)
tagid_listarrayList of tag IDs the user has been hit with
subscribe_scenestringReturn to the channel source of user concern, ADD_STORY_SEARCH Official Account search, ADD_STORY_ACCOUNT_MIGRATION Official Account, ADD_STORY_PROFILE_CARD business card sharing, ADD_STORY_QR_CODE scan two-dimensional code,ADD_SCENE_PROFILE_LINK: clickable name within the graphic page, ADD_SCENE_PROFILE_ITEM: menu option at the upper right corner of the graphic page, ADD_SCREEN_PAID: follow after payment, ADD_SCENE_WECHAT_ADVERTISEMENT: WeChat advertisement, ADD_SCENE_REPRINT: content reposted by others, ADD_SCENE_LIVESTREAM: live streaming via WeChat Channels.ADD_SCENE_CHANNELS WeChat Channels,ADD_SCENE_WXA Weixin Mini Program Attention, ADD_SCENE_OTHERS Other
qr_scenenumberQR code scanning scene (developer customized)
qr_scene_strstringQR code scanning scene description (developer customized)

# 4. Note

If developers have a need to unify user accounts between multiple Official Account, or between Mobile App and Mobile App, they need to go to the WeChat open platform (open.weixin.qq.com) to bind the Official Account template before they can use the UnionID mechanism to meet these needs.

Developers can access basic user information through OpenID.In particular, if the developer has multiple Mobile AppWebsite App and public accounts can distinguish a user's uniqueness by obtaining the unionid in the user's basic information, since the user''s unionid is unique as long as the mobile application, website application, and public account are under the same WeChat open platform account.In other words, the same user, for different applications under the same WeChat open platform, the unionid is the same.

From June 8, 2020, users started paying attention to the source "WeChat advertisement (ADD_SCENE_WECHAT_ADVERTISEMENT)" from "OTHERS" and no longer output profile pictures or nickname information after December 27, 2021.

# 5. Code examples

# 5.1 Normal Requests

Example Requests

{
  "access_token": "ACCESS_TOKEN",
  "openid": "o6_bmjrPTlm6_2sgVt7hMZOPfL2M"
}

Return an example

{
  "subscribe": 1,
  "openid": "o6_bmjrPTlm6_2sgVt7hMZOPfL2M",
  "language": "zh_CN",
  "subscribe_time": 1382694957,
  "unionid": "o6_bmasdasdsad6_2sgVt7hMZOPfL",
  "remark": "",
  "groupid": 0,
  "tagid_list": [
    128,
    2
  ],
  "subscribe_scene": "ADD_SCENE_QR_CODE",
  "qr_scene": 98765,
  "qr_scene_str": ""
}

# 5.2 Error Request

Example Requests

{
  "access_token": "ACCESS_TOKEN",
  "openid": "o6_bmjrPTlm6_2sgVt7hMZOPfL2M"
}

Return an example

{
  "errcode":40013,
  "errmsg":"invalid appid"
}

# 6. Error code

The following is a list of error codes for this interface, other error codes can refer to General error codes

Error codeError DescriptionSolutions
-1system errorThe system is busy, so the developer is asked to try again in a few minutes.
40001invalid credential  access_token isinvalid or not latestAppSecret error while getting access_token, or access_token is invalid.Developers should check that AppSecret is correct, or that they are calling interfaces for the appropriate Official Account
40003invalid openidUser not interested or openid error
40013invalid appidInvalid AppID error

# 7. Scope of application

How this interface can be invoked under different account types:
Official Account Service Account
Certification only 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.
  • Other account types that are not expressly stated may not be called on this interface without special instructions;