internal static GetUserListResultModel Create(JObject obj) { var array = obj["data"]?["openid"] as JArray; var model = new GetUserListResultModel { TotalCount = obj.Value <long>("total"), Count = obj.Value <short>("count"), LastOpenId = obj.Value <string>("next_openid"), OpenIds = array?.Select(i => i.Value <string>()).ToArray() ?? new string[0], }; return(model); }
/// <summary> /// 获取用户列表。 /// </summary> /// <param name="startOpenId">第一个拉取的OPENID,不填默认从头开始拉取</param> /// <returns>获取用户列表结果模型。</returns> public GetUserListResultModel GetUserList(string startOpenId = null) { var url = "https://api.weixin.qq.com/cgi-bin/user/get?access_token=" + _accountModel.GetAccessToken(); if (!string.IsNullOrWhiteSpace(startOpenId)) { url = url + "&next_openid=" + startOpenId; } var content = WeiXinHttpHelper.GetString(url); var obj = JObject.Parse(content); return(GetUserListResultModel.Create(obj)); }