微信查询所有关注该公众号的用户

it2022-06-28  71

using (HttpClient client = new HttpClient()) { var appId = ""; var appSecret = ""; //起始位置,为空则从头开始查询 var next_openid = ""; //注册一次即可 AccessTokenContainer.Register(appId, appSecret); var token = AccessTokenContainer.GetAccessToken(appId); string url = string.Format("https://api.weixin.qq.com/cgi-bin/user/get?access_token={0}", token); if (!string.IsNullOrEmpty(next_openid)) { url += "&next_openid=" + next_openid; } var response = await client.GetAsync(url); var resultStr = await response.Content.ReadAsStringAsync(); GetAllUsersOutput result = JsonConvert.DeserializeObject<GetAllUsersOutput>(resultStr); } public class GetAllUsersOutput { public int total { get; set; } public int count { get; set; } public GetAllUsersData data { get; set; } public string next_openid { get; set; } } public class GetAllUsersData { public List<string> openid { get; set; } }

示例代码

https://github.com/zLulus/NotePractice/blob/dev3/Console/WechatDemo/Program.cs

转载于:https://www.cnblogs.com/Lulus/p/9099251.html


最新回复(0)