Exemplo n.º 1
0
        private IList <ITweet> PullMentionTimeLineTweets(SocialAccount account, int maxNumberOfTweetsRetrieve, DateTime since)
        {
            var mentions = new List <ITweet>();
            var tweets   = _twitterClient.GetMentionsTimeline(maxNumberOfTweetsRetrieve);

            while (tweets != null && tweets.Any())
            {
                if (tweets.First().CreatedAt.ToUniversalTime() <= since)
                {
                    break;
                }

                foreach (var tweet in tweets)
                {
                    if (tweet.CreatedAt.ToUniversalTime() <= since)
                    {
                        break;
                    }
                    mentions.Add(tweet);
                }
                ;

                if (tweets.Any(t => t.CreatedAt.ToUniversalTime() <= since))
                {
                    break;
                }

                var maxId = tweets.Last().Id;
                tweets = _twitterClient.GetMentionsTimeline(maxNumberOfTweetsRetrieve, maxId);

                if (tweets.Count() == 1 && tweets.First().Id == maxId)
                {
                    break;
                }
            }
            return(mentions);
        }