Home > Article > WeChat Applet > WeChat public platform development to obtain followers list
This article introduces how to use advanced interfaces to develop the function of obtaining the follower list on the WeChat public platform.
Official accounts can obtain the account’s follower list through this interface. The follower list consists of a string of OpenID ( The encrypted WeChat account (each user’s OpenID for each official account is unique). A single pull call can pull up to 10,000 OpenIDs of followers, and you can pull multiple times to meet your needs.
Interface call request description
http请求方式: GET(请使用https协议) https://api.weixin.qq.com/cgi-bin/user/get?access_token=ACCESS_TOKEN&next_openid=NEXT_OPENID
Parameter | Whether it is required | Description |
---|---|---|
access_token | is | Call interface credentials |
next_openid | is | The first OPENID to be pulled, if not filled in, it will be pulled from the beginning by default |
Return instructions
Return when correct JSON data packet:
{"total":2,"count":2,"data":{"openid":["","OPENID1","OPENID2"]},"next_openid":"NEXT_OPENID"}
Description | |
---|---|
The total number of users following the public account | |
The number of OPENIDs pulled, the maximum value is 10000 | |
List data, list of OPENID | |
Pull the OPENID of the next user in the list |
{"errcode":40013,"errmsg":"invalid appid"}
Attachment: When the number of followers exceeds 10,000
When the number of followers of the public account exceeds 10,000, you can fill in the value of next_openid and pull the list multiple times to meet the needs. Specifically, when calling the interface, the next_openid value returned from the previous call is used as the next_openid value in the next call. Examples are as follows:公众账号A拥有23000个关注的人,想通过拉取关注接口获取所有关注的人,那么分别请求url如下: https://api.weixin.qq.com/cgi-bin/user/get?access_token=ACCESS_TOKEN 返回结果:
{ "total":23000, "count":10000, "data":{" openid":[ "OPENID1", "OPENID2", ..., "OPENID10000" ] }, "next_openid":"NEXT_OPENID1" }
https://api.weixin.qq.com/cgi-bin/user/get?access_token=ACCESS_TOKEN&next_openid=NEXT_OPENID1 返回结果:
{ "total":23000, "count":10000, "data":{ "openid":[ "OPENID10001", "OPENID10002", ..., "OPENID20000" ] }, "next_openid":"NEXT_OPENID2"}
https://api.weixin.qq.com/cgi-bin/user/get?access_token=ACCESS_TOKEN&next_openid=NEXT_OPENID1 返回结果(关注者列表已返回完时,返回next_openid为空):
$access_token = ""; $url = "https://api.weixin.qq.com/cgi-bin/user/get?access_token=$access_token"; $result = https_request($url); $jsoninfo = json_decode($result, true); var_dump($result);
= "" = "https://api.weixin.qq.com/cgi-bin/user/get?access_token=" = https_request( = json_decode(, (After CMB, the return will be similar to the following:
{ "total":23000, "count":10000, "data":{ "openid":[ "OPENID10001", "OPENID10002", ..., "OPENID20000" ] }, "next_openid":"NEXT_OPENID2" }For numbers exceeding 10,000, just execute the above program in a loop, store these openids in the database, and obtain the list of followers. The main function of this interface is to cooperate with the interface to obtain basic user information and user grouping to obtain the basic information and grouping of all followers. For more articles related to WeChat public platform development and obtaining followers list, please pay attention to the PHP Chinese website!