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; }
}
示例代码
示例代码