微信查詢所有關注該公眾號的用戶


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; }
}

示例代碼

示例代碼


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM