Retweet Count, Favourite Count, Favourited By

May 6, 2013 at 9:38 AM
How do I get the following information for each tweet:

• No of retweets
• No of add to favorites
• People who added this tweet to favorites
• Replies

Thank you.
Coordinator
May 10, 2013 at 6:08 AM
Hi,

RetweetCount and FavoriteCount are on the Status entity. Note: The numbers aren't always updated immediately. This is because of Twitter's eventual consistency data model, where the values are updated when their system has time to do it.

The Twitter API doesn't have queries for people who favorite or replies. You could try to get this the long way around by querying friend tweets and correlating their actions. However, that wouldn't be 100% accurate because more than just friends will favorite and reply. You can also check out UserStream to capture events, but that's live data, rather than historical.

@JoeMayo
May 10, 2013 at 6:26 AM
I tried status entity, but I am not able to get FavoriteCount property. I do get Favorited property, but that's not the same.
Here is my query:

var queryResponse = from tweet in twitterCtx.Status
                    where tweet.Type == StatusType.User && tweet.ScreenName == Screen_Name && tweet.Count == 200
                    select tweet;

foreach (var q in queryResponse)
                        {
                            DataRow dr = dtScreenNameTweets.NewRow();
                            dr["CREATED_AT"] = q.CreatedAt;
                            dr["UserName"] = q.User.Name;
                            dr["Screen_Name"] = q.User.Identifier.ScreenName;
                            dr["TWITTER_USER_ID"] = q.User.Identifier.UserID;
                            dr["Description"] = q.User.Description;
                            dr["Picture_URL"] = q.User.ProfileImageUrl;
                            dr["TWEET_TEXT"] = q.Text.Replace("'", " ");
                            dr["Tweet_ID"] = q.StatusID;
                            dr["Lat"] = q.Coordinates.Longitude;
                            dr["Lon"] = q.Coordinates.Latitude;
                            dr["Location"] = q.User.Location;
                            dr["Followers"] = q.User.FollowersCount;
                            dr["Following"] = q.User.FriendsCount;
                            dr["Tweets_Count"] = q.User.StatusesCount;
                            dr["Retweet_Count"] = q.RetweetCount;
                            dtScreenNameTweets.Rows.Add(dr);
                        }


Coordinator
May 10, 2013 at 6:31 AM
FavorteCount is new. I added it on March 28th, so it should be in the latest release, which is April 8th.

@JoeMayo
May 10, 2013 at 6:38 AM
Thanks, Joe.


May 10, 2013 at 7:11 AM
I got the latest binaries for LINQToTwitter. I am getting FavoritesCount under: q.User.FavoritesCount not as q.FavoritesCount (Erefr to the query posted earlier in this thread). Will it still give me the favorites count for each tweet?


Coordinator
May 10, 2013 at 7:27 AM
It should be on Status too, only singular - FavoriteCount. The difference is that on Status, it's the number of times the tweet has been favorited, whereas on User it's the number of tweets the user has ever favorited.

@JoeMayo
May 10, 2013 at 7:45 AM
I tried, its not appearing in the list of properties for status. Can you please post a sample query?


Coordinator
May 10, 2013 at 8:05 AM
I just ran this - the results are 0 for FavoriteCount, but you can use a tweet ID that does have favorites:
        void SingleStatusQuery(TwitterContext twitterCtx)
        {
            const string TweetID = "10520783556";

            var tweetsStatus =
                from tweet in twitterCtx.Status
                where tweet.Type == StatusType.Show &&
                      tweet.ID == TweetID
                select tweet;

            Console.WriteLine("\nRequested Tweet: \n");

            var tweets = tweetsStatus.ToList();

            tweets.ForEach(
                tweet => Console.WriteLine(
                "Name: {0}, Tweet: {1}, Favorite Count: {2}\n",
                tweet.User.Name, tweet.Text, tweet.FavoriteCount));
        }
The latest release is 2.1.05. I updated from NuGet to make sure I had the latest. I also downloaded the binaries and checked the version from file properties to ensure I deployed the proper version. Of course, I have the latest version of the code on my development machine, but the code you see above was from a project with a NuGet reference.

@JoeMayo
Coordinator
May 10, 2013 at 8:07 AM
May 10, 2013 at 8:27 AM
Dear Joe,

Got it. It was my mistake, the library didn't get update properly. Sorry for the trouble. Its working now.