1

I'm trying to use Tweetinvi to retrieve all the tweets made by a particular screen name.

I've tried GetUserTimeLine (see below) but it shows tweets from all the people I follow instead of just mine.

        IUser user = Tweetinvi.User.GetUserFromScreenName("SCREEN_NAME");

        // Create a parameter for queries with specific parameters
        var timelineParameter = Timeline.CreateUserTimelineRequestParameter(user);
        timelineParameter.ExcludeReplies = true;
        timelineParameter.TrimUser = true;
        timelineParameter.IncludeRTS = false;

        var tweets = Timeline.GetUserTimeline(timelineParameter);

        return tweets;

Thanks, Travis

Travis
  • 67
  • 2
  • 7

2 Answers2

2

A little late, but maybe useful for others (using the Tweetinvi NuGet 0.9.12.1) :

            Tweetinvi.Core.Interfaces.IUser user2 = Tweetinvi.User.GetUserFromScreenName("StackOverflow");

            var userTimelineParam = new Tweetinvi.Core.Parameters.UserTimelineParameters
            {
                MaximumNumberOfTweetsToRetrieve = 100,
                IncludeRTS=true 
            }; 

            List<Tweetinvi.Core.Interfaces.ITweet> tweets2= new List<Tweetinvi.Core.Interfaces.ITweet>();
            tweets2 = Timeline.GetUserTimeline(user2, userTimelineParam).ToList();

            foreach (Tweetinvi.Core.Interfaces.ITweet prime2 in tweets2)
            {
                Debug.WriteLine(prime2.CreatedAt+" "+prime2.Text+" "+prime2.Id.ToString());
            }
BernieSF
  • 1,722
  • 1
  • 28
  • 42
1

Twitter does not provide such endpoint. Therefore you will need to filter the tweets that have not been created by yourself.

Simply use linq (using System.Linq) to filter down the result after your code:

var tweetsPublishedByMyself = tweets.Where(x => x.Creator.Equals(user)).ToArray();
user2465083
  • 595
  • 3
  • 12
  • not sure this is the right answer - how to get all tweets of other user (not me) - for example CNN, Bloomberg (I know the limit is 3,200 tweets) but was unable to implement it.. – user1025852 Dec 27 '14 at 19:32
  • @user1025852 Just because the variable name is "tweetsPublishedByMyself" doesn't mean it will hold tweets by yourself, just change the "user" inside the lambda expression to the user you want to get the tweets from. –  Oct 21 '15 at 06:32