Home  >  Article  >  WeChat Applet  >  WeChat public platform development to obtain user basic information

WeChat public platform development to obtain user basic information

高洛峰
高洛峰Original
2017-03-04 11:35:382201browse

1. Interface for obtaining basic user information

After the follower interacts with the official account, the official account can obtain the follower’s OpenID (encrypted WeChat ID) , each user's OpenID for each official account is unique. For different official accounts, the openid of the same user is different). Official accounts can use this interface to obtain basic user information based on OpenID, including nickname, avatar, gender, city, language and follow time.

Obtain basic user information

Developers can obtain basic user information through OpenID. Please use https protocol.

Interface call request description

http请求方式: GET
https://api.weixin.qq.com/cgi-bin/user/info?access_token=ACCESS_TOKEN&openid=OPENID&lang=zh_CN

Parameter description

Parameter Is it necessary Description
access_token Yes Call interface credentials
openid is the identifier of an ordinary user , unique to the current public account
lang No Return to the country and region language version, zh_CN simplified, zh_TW traditional, en English

Return description

Under normal circumstances, WeChat will return the following JSON data packet to the public account:

{    "subscribe": 1,
    "openid": "o7Lp5t6n59DeX3U0C7Kric9qEx-Q",
    "nickname": "方倍",
    "sex": 1,
    "language": "zh_CN",
    "city": "深圳",
    "province": "广东",
    "country": "中国",
    "headimgurl": "http://wx.qlogo.cn/mmopen/Kkv3HV30gbEZmoo1rTrP4UjRRqzsibUjT9JClPJy3gzo0NkEqzQ9yTSJzErnsRqoLIct5NdLJgcDMicTEBiaibzLn34JLwficVvl6/0",
    "subscribe_time": 1389684286}

Parameter description

Parameters Description
subscribe Whether the user subscribes to the public account ID, when the value is 0, It means that this user has not followed the official account and cannot retrieve other information.
openid The user’s identifier, unique to the current public account
nickname The user’s nickname
sex The gender of the user, when the value is 1, it is male, when the value is 2, it is female, when the value is 0, it is unknown
city The city where the user is located
country The country where the user is located
province Province where the user is located
language The user’s language, simplified Chinese is zh_CN
headimgurl User avatar, the last value represents the size of the square avatar (0, 46, 64, 96, 132 values ​​are available, 0 represents a 640*640 square avatar), this item is empty when the user does not have an avatar
subscribe_time The time the user pays attention to is the timestamp. If the user has followed multiple times, the last follow time

will be returned by WeChat when there is an error. An example of the JSON data packet is as follows (this example is an invalid AppID error) :

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

2. Program Implementation

 = "5ic8RoqZd7IBUtE0aGXUhcdKBnrwlO1iqtvyJJUgIcDcopJIH7x90QH4yiK_z08fqp4WOD7kfKPDtET29BRYNZO-sSIITaxIj4u72LYAYcFH6t1fiSVzjUuqYWOtHiw0LGDorxx5Qj6SN0Z7GtYGTA"="o7Lp5t6n59DeX3U0C7Kric9qEx-Q" = "https://api.weixin.qq.com/cgi-bin/user/info?access_token=&openid=&lang=zh_CN" = https_request((

For more articles related to the development of WeChat public platform to obtain user basic information, please pay attention to the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn