Reputation: 731
this is the my first question in SO witch I use alot btw :). this is the problem/challenge:
I'm building a service where the user can select a number of his facebook and twitter friends, he will then get a combined list of tweets and statuses of those. Facebook was no problem using batch request was very useful and easy to implement. Im trying to get the same result from twitter, but this seems harder then it seem.
I have a list of all my friends (name and user_id), I want to select a few of those friends and retrieve their tweets. Im using linqToTwitter, a direct HTTP request is also welcome :).
this is what im trying:
var tweetsResult =
(from search in twitterCtx.Search
where search.Type == SearchType.Search &&
search.Query == "from:cinek24 OR from:blaba"
select search).Single();
this works with public users like cnn but not private friends, and yes i have valid tokens.
Upvotes: 1
Views: 1171
Reputation: 7513
Here's how you would do the users look-up in LINQ to Twitter:
var users =
(from user in twitterCtx.User
where user.Type == UserType.Lookup &&
user.ScreenName == "cinek24,blaba"
select user)
.ToList();
users.ForEach(user => Console.WriteLine("Name: " + user.Name));
More info here:
Once you have the users, then you'll have to query each of them for their tweets because the user lookup will only return their last tweet, like this:
var statusTweets =
from tweet in twitterCtx.Status
where tweet.Type == StatusType.User
&& tweet.ScreenName == "cinek24"
&& tweet.Count == 40
select tweet;
tweets.ToList().ForEach(
tweet => Console.WriteLine(
"Name: {0}, Tweet: {1}\n",
tweet.User.Name, tweet.Text));
More info on that query here:
Joe
Upvotes: 3
Reputation: 14334
This is the API call you need - users/lookup
https://api.twitter.com/1/users/lookup.json?screen_name=twitterapi,twitter,edent,MQoder&include_entities=true
This will return the most recent tweet from all those screen_names. You can also use user_ids if you prefer.
Upvotes: 2