示例#1
0
        public async ValueTask <User> UserInfo(string screenName)
        {
            var user = await oAuthApiRequest
                       .GetAsync <User>("https://api.twitter.com/1.1/users/show.json",
                                        new[] {
                TwitterOptions.IncludeEntities(),
                TwitterOptions.ExtendedTweetMode(),
                TwitterOptions.ScreenName(screenName)
            })
                       .ConfigureAwait(false);

            var userConnections = UserConnectionsService.LookupUserConnections(user.Id);

            user.IsFollowing  = userConnections?.IsFollowing ?? false;
            user.IsFollowedBy = userConnections?.IsFollowedBy ?? false;
            return(user);
        }
示例#2
0
        private async ValueTask <IEnumerable <TwitterStatus> > UpdateUserConnections(IEnumerable <TwitterStatus> statuses)
        {
            // The timeline API's no longer report Following and FollowedBy status and the
            // friendship lookup connections API is rate limited. Keep a cached list and update the
            // fields accordingly.
            await UserConnectionsService
            .AddUserIdsAsync(statuses.Select(status => status.OriginatingStatus.User.Id), this)
            .ConfigureAwait(false);

            // Needed to set the Following and FollowedBy properties because the
            // timeline API's no longer report these fields
            foreach (var status in statuses)
            {
                status.UpdateFromStatus(status);
            }
            return(statuses);
        }