How to verify that the user is concerned about the public number when PHP WeChat activity

Source: Internet
Author: User
Tags openid
This article brings you the content is about PHP activity how to verify whether the user is concerned about the public number, there is a certain reference value, the need for friends can refer to, I hope to help you.

When we do activities, some activities require users to pay attention to the public number in order to continue activities or send gifts. This requires us to verify whether the user has been concerned, so we need to use the----to get the user basic information interface

Get basic user information (including Unionid mechanism)

The developer can use OpenID to get basic user information. Please use the HTTPS protocol.

Interface 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 whether you must Description
Access_token Is Invoking interface Credentials
Openid Is The identity of the ordinary user, the current public number only
Lang Whether Back to national language version, ZH_CN simplified, zh_tw traditional, en English

This interface only needs to pass in its own public number token and the user's OpenID can obtain the user's basic information

Parameters Description
Subscribe Whether the user subscribes to the public ID, which is 0 o'clock, indicates that the user is not interested in the public number and pulls out the rest of the information.
Openid The user's identity, which is unique to the current public number
Nickname User's nickname
Sex The gender of the user, the value of 1 o'clock is male, the value is 2 o'clock is female, the value is 0 o'clock is unknown
City The city where the user resides
Country User Country
Province User Province
Language User's language, Simplified Chinese is zh_cn
Headimgurl User picture, the last value represents the size of the square head (there are 0, 46, 64, 96, 132 values are optional, 0 represents the 640*640 square head), the user does not have an avatar when the item is empty. If the user changes the avatar, the original avatar URL will expire.
Subscribe_time The user is concerned about time, timestamp. If the user has been concerned more than once, take the last attention time
Unionid This field only appears if the user has bound the public number to an open platform account.
Remark Public operator comments on fans, public number operators can face fans in the public platform user management community to add notes
GroupID The group ID of the user (compatible with the old user group interface)
Tagid_list List of tag IDs that the user was tagged in
Subscribe_scene Return to the source of the user's attention, Add_scene_search public Search, add_scene_account_migration public migration, Add_scene_profile_card business card sharing, Add_scene_qr_ Code scan QR Code, add_scene profile LINK text page name click, Add_scene_profile_item page top right corner menu, Add_scene_paid pay attention, Add_scene_ OTHERS Other
Qr_scene QR Code sweep code scene (developer Custom)
Qr_scene_str QR Code sweep code Scene description (developer customization)

One of the columns is subscribe this field can be used to verify whether the user has been concerned about the conditions, when subscribe is 1 o'clock to prove that the user has been concerned about our public number can continue to the relevant activities, when the 0 o'clock on behalf of the user is not concerned about, At this point we need to guide the user to follow the relevant public number (however, it is necessary to master the relevant guidance skills, to avoid being warned, can be implicitly guided such as the award contact customer Service and other words)

If your activity needs to be verified every time, then it is not recommended to do cache, to avoid user attention after the cancellation to take wool. However, if your activity is not limited to the requirement that the user has been concerned about in the future, it is advisable to put it into the Redis permanent cache.

Specific ways to get tokens and curl is not in this chapter in detail you can look at the previous chapters of the relevant code can be, after all, it is very simple to get user OpenID according to code to obtain tokens in the public information, Finally, curl off the address above to get the user information.

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.