Question

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.

Was it helpful?

Solution

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:

http://linqtotwitter.codeplex.com/wikipage?title=Querying%20User%20Details&referringTitle=Getting%20User%20Information

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:

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

Joe

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top