Filter Tweets by screen name

Jan 22, 2012 at 4:26 PM

Hi Gyus,

Im probably doing somethign wrong, but I just changed "hell world" query from homepage into

 

 
where tweet.Type == StatusType.Public && tweet.User.Identifier.ScreenName == "BenThePCGuy"

And then I call ToList() method colletions is empty. Do you have any ideas what is good way to get tweets by screen name?

Thanks.

Coordinator
Jan 22, 2012 at 5:14 PM

Hi,

Maybe this will work better for you:

        private static void UserStatusByNameQueryDemo(TwitterContext twitterCtx)
        {
            Console.WriteLine();

            var lastN = 11;
            var screenName = "JoeMayo";

            var statusTweets =
                from tweet in twitterCtx.Status
                where tweet.Type == StatusType.User
                      && tweet.ScreenName == screenName
                      && tweet.Count == lastN
                select tweet;

            foreach (var tweet in statusTweets)
            {
                Console.WriteLine(
                    "(" + tweet.User.Identifier.ID + ")" +
                    "[" + tweet.User.Identifier.ScreenName + "]" +
                    tweet.User.Name + ", " +
                    tweet.Text + ", " +
                    tweet.CreatedAt);
            }
        }

More info here:

http://linqtotwitter.codeplex.com/wikipage?title=Querying%20the%20User%20Timeline&referringTitle=Making%20Status%20Queries%20and%20Calls

There are more examples in the downloadable source code too, covering C# Console, VB Console, ASP.NET Web Forms, ASP.NET MVC, Silverlight, and Windows Phone 7.

Joe