Esempio n. 1
0
        private long[] GetFriendIds(long userId)
        {
            var twitterQuery = TwitterQuery.Create(TwitterConstants.FriendIdsUrl);

            twitterQuery.AddParameter("user_id", userId);
            twitterQuery.AddParameter("count", TwitterConstants.MaxFriendsToRetrive);
            string result    = ExecuteQuery(twitterQuery);
            var    resultIds = JsonHelper.DeserializeToClass <ResultIds>(result);

            return(resultIds.Ids ?? new long[0]);
        }
Esempio n. 2
0
        public UserEntity GetAuthenticatedUser()
        {
            TwitterQuery twitterQuery = TwitterQuery.Create(TwitterConstants.AuthUserUrl);

            twitterQuery.AddParameter("skip_status", "true");
            twitterQuery.AddParameter("include_entities", "true");
            string     result = ExecuteQuery(twitterQuery);
            UserEntity user   = JsonHelper.DeserializeToClass <UserEntity>(result);

            return(user);
        }
        private List <UserEntity> GetFriendsFromIds(long[] friendIds)
        {
            var    twitterQuery = TwitterQuery.Create(HttpMethod.Post, TwitterConstants.UsersDataUrl);
            string userIdsParam = GenerateIdsParameter(friendIds);

            twitterQuery.AddParameter("user_id", userIdsParam);
            string            result   = ExecuteQuery(twitterQuery);
            List <UserEntity> userList = JsonHelper.DeserializeToClass <List <UserEntity> >(result);

            return(userList ?? new List <UserEntity>());
        }
Esempio n. 4
0
        public List <TweetEntity> GetUserTweetList(long userId, int count, bool includeRetweet = false)
        {
            var twitterQuery = TwitterQuery.Create(TwitterConstants.UserTweetsUrl);

            twitterQuery.AddParameter("user_id", userId);
            twitterQuery.AddParameter("include_rts", includeRetweet);
            twitterQuery.AddParameter("exclude_replies", false);
            twitterQuery.AddParameter("contributor_details", false);
            twitterQuery.AddParameter("count", count);
            twitterQuery.AddParameter("trim_user", false);
            twitterQuery.AddParameter("include_entities", true);
            twitterQuery.AddParameter("tweet_mode", "extended");

            string result    = ExecuteQuery(twitterQuery);
            var    tweetList = JsonHelper.DeserializeToClass <List <TweetEntity> >(result);

            return(tweetList ?? new List <TweetEntity>());
        }
Esempio n. 5
0
        private List <UserEntity> GetFriendsFromIds(long[] friendIds)
        {
            // Twitter allows only MaxFriendsToLookupPerCall per query, so make multiple calls
            var friendList = new List <UserEntity>();

            for (int index = 0; index < friendIds.Length; index += TwitterConstants.MaxFriendsToLookupPerCall)
            {
                var    twitterQuery      = TwitterQuery.Create(TwitterConstants.UsersDataUrl);
                var    friendIdsToLookup = friendIds.Skip(index).Take(TwitterConstants.MaxFriendsToLookupPerCall).ToArray();
                string userIdsParam      = GenerateIdsParameter(friendIdsToLookup);
                twitterQuery.AddParameter("user_id", userIdsParam);
                string queryResult = ExecuteQuery(twitterQuery);
                var    friends     = JsonHelper.DeserializeToClass <List <UserEntity> >(queryResult);
                if (friends == null)
                {
                    break;
                }
                friendList.AddRange(friends);
            }
            return(friendList);
        }