摘要:
step 1: 向微信官方服务器发起请求,获取token
step 2: 向微信官方服务器发起请求,获取已关注用户的openid的集合,每次上限10000个,循环。
step 3:根据已获取的openid集合逐个向向微信官方服务器发起请求,获取该用户的详细信息。
具体实现过程:
官网操作手册:https://developers.weixin.qq.com/doc/offiaccount/User_Management/Getting_a_User_List.html
接口调用请求说明
http请求方式: GET
http请求方式: GET(请使用https协议)
https://api.weixin.qq.com/cgi-bin/user/get?access_token=ACCESS_TOKEN&next_openid=NEXT_OPENID
此函数仅获取已关注用户的OPENID列表
step 1:
next_openid 第一个拉取的OPENID,不填默认从头开始拉取
https://api.weixin.qq.com/cgi-bin/user/get?access_token=ACCESS_TOKEN&next_openid=
output:
正确时返回JSON数据包
{
"total":2,
"count":2,
"data":{
"openid":["OPENID1","OPENID2"]},
"next_openid":"NEXT_OPENID"
}
设计返回结构
/// <summary>
/// 已关注用OpenID用户列表集合
/// </summary>
public class UserOpenIdList
{
public int total { get; set; }
public int count { get; set; }
public OpenIds data { get; set; }
public string next_openid { get; set; }
}