How to get name and tweet from people who retweet a specific tweet

Jul 20, 2011 at 4:01 PM

Hi guys,

I got a that question : How to get name and tweet from people who retweet a specific tweet ?

I've seen in the doc that we can get the retweets of a status. But, when I do that, i just got the same tweet and the same UserName, which is probably automaticaly retweeted.

What I want to do is just got the name and the tweet of people who retweet a tweet.


Example :

Mr A tweets : "Hello" and I know that it was retweeted 21 times.

So, I wanna get the 21 name (or UserId) and the tweet.

 

Thanks a lot

Jul 25, 2011 at 8:43 AM

Any idea ?

Coordinator
Jul 26, 2011 at 2:35 PM

Hi,

Sorry it took so long, but I needed to block some time to look at this more closely.  Here's a demo of a work-around you can use:

        private static void RetweetsQueryDemo(TwitterContext twitterCtx)
        {
            var friendTweets =
                from tweet in twitterCtx.Status
                where tweet.Type == StatusType.Retweets &&
                      tweet.ID == "93684902972760066"
                select tweet;

            Console.WriteLine("\nReTweets: \n");
            foreach (var tweet in friendTweets)
            {
                Console.WriteLine(
                     "\nUser: " + tweet.User.Identifier.ScreenName +
                    "\nTweet: " + tweet.Retweet.Text +
                    "\nTweet ID: " + tweet.Retweet.ID + "\n");
            }
        }

From the perspective of a Retweet, the User is the person who performed the Retweet.  I can see where this can be confusing and need to update my demo and refactor the Retweet object property name to reflect what's really happening.  The code above works and will hopefully get you started.

@JoeMayo

Jul 26, 2011 at 2:36 PM

Thank you, thank you so much Joe !!!

 

I gonna try it as soon as possible :)

Aug 10, 2011 at 2:31 PM
Edited Aug 10, 2011 at 2:46 PM

Hi Joe, I had an other application to work on, so I hadn't try your code since today.

 

When I try it on The LinqToTwitterDemo application I downloaded on codeplex, it throw an excpetion "Error while querying twitter".

 

It it thrown on this method : public string QueryTwitter<T>(Request request, IRequestProcessor<T> reqProc) , in TwitterExecute.cs

 

I have just replace the original query : 

 

 

 var tweets =
                (from tweet in ctx.Status
                 where tweet.Type == StatusType.Public
                 select tweet)
                .ToList();

            tweets.ForEach(tweet => 
                Console.WriteLine(
                    "User: {0}\nTweet: {1}\n", 
                    tweet.User.Identifier.ScreenName, 
                    tweet.Text));

 

by your ones : 

 

 

            var friendTweets =
                from tweet in twitterCtx.Status
                where tweet.Type == StatusType.Retweets &&
                      tweet.ID == "93684902972760066"
                select tweet;

            Console.WriteLine("\nReTweets: \n");
            foreach (var tweet in friendTweets)
            {
                Console.WriteLine(
                     "\nUser: " + tweet.User.Identifier.ScreenName +
                    "\nTweet: " + tweet.Retweet.Text +
                    "\nTweet ID: " + tweet.Retweet.ID + "\n");
            }
        

 

I can't understand why ?

 

Any idea ?

 

Thanks Joe

Coordinator
Aug 10, 2011 at 8:29 PM

Hi,

1. Look inside of the exception to see what it says.  There might be a response property that provides more info from Twitter.

2. Did you authenticate?  The Program.cs file in LinqToTwitterDemo.cs has code that shows how to use OAuth.

Joe