WeChat public platform development to obtain basic user information

Source: Internet
Author: User
Tags openid
After the consumer and the public account generate a message interaction, the public account can obtain the OpenID of the consumer (encrypted number. each user has a unique OpenID for each public account. For different public accounts, the openid of the same user is different ). You can use this interface to obtain basic user information based on the OpenID, including nicknames, portraits, gender, city, language, and focus time. 1. interface for obtaining basic user information

After the consumer and the public account generate a message interaction, the public account can obtain the OpenID of the consumer (encrypted number. each user has a unique OpenID for each public account. For different public accounts, the openid of the same user is different ). You can use this interface to obtain basic user information based on the OpenID, including nicknames, portraits, gender, city, language, and focus time.

Obtain basic user information

You can use OpenID to obtain basic user information. Use https protocol.

API call request description

Http request method: GEThttps: // api.weixin.qq.com/cgi-bin/user/info? Access_token = ACCESS_TOKEN & openid = OPENID & lang = zh_CN

Parameter description

Parameters Required? Description
Access_token Yes Interface call credential
Openid Yes The identifier of a common user, which is unique to the current public account.
Lang No Return to the Chinese language version, zh_CN simplified, zh_TW traditional, en English

Return description

Normally, the following JSON data packet is returned to the public account:

{"Subscribe": 1, "openid": "o7Lp5t6n59DeX3U0C7Kric9qEx-Q", "nickname": "", "sex": 1, "language": "zh_CN ", "city": "Shenzhen", "province": "Guangdong", "country": "China", "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. if the value is 0, the user does not pay attention to the public account and cannot obtain other information.
Openid User ID, which is unique to the current public account
Nickname User nickname
Sex Gender of the user. if the value is 1, the user is male. if the value is 2, the user is female. if the value is 0, the user is unknown.
City User's City
Country Country of the user
Province Province
Language The user's language. the simplified Chinese name is zh_CN.
Headimgurl User profile picture. the last value indicates the size of the square profile picture (optional values include 0, 46, 64, 96, and 132, and 0 indicates the size of the 640*640 square profile picture). This parameter is blank when the user does not have the profile picture.
Subscribe_time The user's attention time, which is the timestamp. If the user has followed the last time

When an error occurs, an error code or other information is returned. An example of a JSON data packet is as follows (this example is an invalid AppID error ):

{"errcode":40013,"errmsg":"invalid appid"}
II. 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 public platform development and user basic information, please follow the PHP Chinese network!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.