Ejemplo n.º 1
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);
        }