1

I want to query tweets by user ID. I implemented the code to query tweets by username with using from operator in the query:

if (!string.IsNullOrWhiteSpace(twitterUsername)) {
      var searchResponse = (from srch in twitterContext.Search where  
        srch.Type == SearchType.Search &&
        srch.Query == "some text from:" + twitterUsername 
        select srch).SingleOrDefault();
}

Now I need the code which will query tweets by user ID, but I cannot find any solution except to call twitter API to get tweeter username by user ID and then call the code above with returned username.

Is there any simpler solution, with one API call.

Iamat8
  • 3,888
  • 9
  • 25
  • 35
carpics
  • 2,272
  • 4
  • 28
  • 56

1 Answers1

1

You can use a Status/User query, like this:

        var tweets =
            await
            (from tweet in twitterCtx.Status
             where tweet.Type == StatusType.User &&
                   tweet.UserID == twitterUserId
             select tweet)
            .ToListAsync();

You can get more details in the LINQ to Twitter Documentation.

Joe Mayo
  • 7,501
  • 7
  • 41
  • 60