示例#1
0
 /// <summary>
 /// 批量获取微信用户信息
 /// </summary>
 /// <param name="openId"></param>
 /// <returns></returns>
 public async Task <BatchGetUserInfoJsonResult> GetBatchUserInfoAsync(string appId, List <string> openIdList)
 {
     return(await UserApi.BatchGetUserInfoAsync(appId, openIdList.Select(p => new BatchGetUserInfoData
     {
         openid = p,
         LangEnum = Language.zh_CN
     }).ToList()));
 }
示例#2
0
        public async Task <List <WxUser> > GetUsersAsync(string accessTokenOrAppId, List <string> openIds)
        {
            var users = new List <WxUser>();
            var num   = TranslateUtils.Ceiling(openIds.Count, 100);

            for (var i = 0; i < num; i++)
            {
                var pageOpenIds = openIds.Skip(i * 100).Take(100);

                var userList = pageOpenIds.Select(openId => new BatchGetUserInfoData
                {
                    openid   = openId,
                    LangEnum = Language.zh_CN
                })
                               .ToList();
                var userResult = await UserApi.BatchGetUserInfoAsync(accessTokenOrAppId, userList);

                users.AddRange(userResult.user_info_list.Select(GetWxUser));
            }

            users = users.OrderByDescending(x => x.SubscribeTime).ToList();

            return(users);
        }