0

I am using the linqtotwitter (v3.1.2) library to stream tweets into an app but we don't want to process retweets. When I received a retweet the properties retweeted and RetweetedStatus.ID are always false and 0.

Is this a bug in the library? I have looked at the source code in GitHub and it looks like it should work.

At the moment I just checking to see if the tweet starts with "RT " but that isn't 100% accurate of course.

Daniel Mann
  • 57,011
  • 13
  • 100
  • 120
slarge
  • 637
  • 1
  • 7
  • 19
  • 1
    So you believe the bug is in the library and no-one else has noticed? The simpler explanation is a bug in your code which you haven't posted because you already know it is wrong. – stark Aug 04 '15 at 11:01
  • Useful comment!! In the code, when I debug, the LinqToTwitter.Status object which represents a tweet contains no indication, in the retweeted or RetweetedStatus.ID properties, that the tweet is a retweet. Not saying this isn't an issue with my code but seems these are set in the object returned by LinqToTwitter. – slarge Aug 04 '15 at 11:54

2 Answers2

0

This appears to be a bug in the library. I have coded around the issue by checking if the tweet text begins with "RT ". Not ideal but it worked for my purpose.

slarge
  • 637
  • 1
  • 7
  • 19
0

The Twitter API sets retweeted to false, which is why the Retweeted property in the returned Status entity is false. Given this, there are two things you can do to track Retweets:

  1. You can check for the tweets starting with RT like you do because some people still do retweets like this, rather than clicking the Retweet button.
  2. Look at the RetweetedStatus property of the Status entity. If it is a retweet, this will be a valid Status instance. If it is not a retweet, RetweetedStatus will be null.

Like I said, the Twitter API is sending false. Here's the raw JSON for a retweet:

{
    "created_at": "Tue Dec 15 17:41:31 +0000 2015",
    "id": 676819388972994560,
    "id_str": "676819388972994560",
    "text": "RT @Dotnetster: Favourites.io built with LinqToTwitter @JoeMayo.  Search and tag your Twitter Favourites. https:\/\/t.co\/CBkJL4KS5Q",
    "source": "\u003ca href=\"http:\/\/twitter.com\" rel=\"nofollow\"\u003eTwitter Web Client\u003c\/a\u003e",
    "truncated": false,
    "in_reply_to_status_id": null,
    "in_reply_to_status_id_str": null,
    "in_reply_to_user_id": null,
    "in_reply_to_user_id_str": null,
    "in_reply_to_screen_name": null,
    "user": {
        "id": 15411837,
        "id_str": "15411837",
        "name": "Joe Mayo",
        "screen_name": "JoeMayo",
        "location": "Las Vegas, NV",
        "description": "Author, Consultant, and Instructor. Microsoft .NET MVP. #VegasTech",
        "url": "http:\/\/t.co\/8atdOuFAEx",
        "entities": {
            "url": {
                "urls": [{
                    "url": "http:\/\/t.co\/8atdOuFAEx",
                    "expanded_url": "http:\/\/www.mayosoftware.com",
                    "display_url": "mayosoftware.com",
                    "indices": [0, 22]
                }]
            },
            "description": {
                "urls": []
            }
        },
        "protected": false,
        "followers_count": 2578,
        "friends_count": 274,
        "listed_count": 174,
        "created_at": "Sun Jul 13 04:35:50 +0000 2008",
        "favourites_count": 12,
        "utc_offset": -28800,
        "time_zone": "Pacific Time (US & Canada)",
        "geo_enabled": true,
        "verified": false,
        "statuses_count": 2984,
        "lang": "en",
        "contributors_enabled": false,
        "is_translator": false,
        "is_translation_enabled": false,
        "profile_background_color": "FFFFFF",
        "profile_background_image_url": "http:\/\/abs.twimg.com\/images\/themes\/theme19\/bg.gif",
        "profile_background_image_url_https": "https:\/\/abs.twimg.com\/images\/themes\/theme19\/bg.gif",
        "profile_background_tile": false,
        "profile_image_url": "http:\/\/pbs.twimg.com\/profile_images\/456514674377256960\/PiL4qsWR_normal.jpeg",
        "profile_image_url_https": "https:\/\/pbs.twimg.com\/profile_images\/456514674377256960\/PiL4qsWR_normal.jpeg",
        "profile_banner_url": "https:\/\/pbs.twimg.com\/profile_banners\/15411837\/1398199881",
        "profile_link_color": "3B94D9",
        "profile_sidebar_border_color": "FFFFFF",
        "profile_sidebar_fill_color": "F6FFD1",
        "profile_text_color": "333333",
        "profile_use_background_image": false,
        "has_extended_profile": false,
        "default_profile": false,
        "default_profile_image": false,
        "following": true,
        "follow_request_sent": false,
        "notifications": true
    },
    "geo": null,
    "coordinates": null,
    "place": null,
    "contributors": null,
    "retweeted_status": {
        "created_at": "Tue Dec 15 17:34:26 +0000 2015",
        "id": 676817605064290306,
        "id_str": "676817605064290306",
        "text": "Favourites.io built with LinqToTwitter @JoeMayo.  Search and tag your Twitter Favourites. https:\/\/t.co\/CBkJL4KS5Q",
        "source": "\u003ca href=\"http:\/\/twitter.com\" rel=\"nofollow\"\u003eTwitter Web Client\u003c\/a\u003e",
        "truncated": false,
        "in_reply_to_status_id": null,
        "in_reply_to_status_id_str": null,
        "in_reply_to_user_id": null,
        "in_reply_to_user_id_str": null,
        "in_reply_to_screen_name": null,
        "user": {
            "id": 26903787,
            "id_str": "26903787",
            "name": "Ross McLoughlin",
            "screen_name": "Dotnetster",
            "location": "",
            "description": "Favourites.io",
            "url": "http:\/\/t.co\/acXDZ35G1d",
            "entities": {
                "url": {
                    "urls": [{
                        "url": "http:\/\/t.co\/acXDZ35G1d",
                        "expanded_url": "http:\/\/www.favourites.io",
                        "display_url": "favourites.io",
                        "indices": [0, 22]
                    }]
                },
                "description": {
                    "urls": []
                }
            },
            "protected": false,
            "followers_count": 206,
            "friends_count": 320,
            "listed_count": 52,
            "created_at": "Fri Mar 27 00:41:29 +0000 2009",
            "favourites_count": 1393,
            "utc_offset": 0,
            "time_zone": "Dublin",
            "geo_enabled": false,
            "verified": false,
            "statuses_count": 6662,
            "lang": "en",
            "contributors_enabled": false,
            "is_translator": false,
            "is_translation_enabled": false,
            "profile_background_color": "000000",
            "profile_background_image_url": "http:\/\/pbs.twimg.com\/profile_background_images\/182308454\/twitter.jpg",
            "profile_background_image_url_https": "https:\/\/pbs.twimg.com\/profile_background_images\/182308454\/twitter.jpg",
            "profile_background_tile": false,
            "profile_image_url": "http:\/\/pbs.twimg.com\/profile_images\/459298001505099777\/lQd1OjeL_normal.jpeg",
            "profile_image_url_https": "https:\/\/pbs.twimg.com\/profile_images\/459298001505099777\/lQd1OjeL_normal.jpeg",
            "profile_link_color": "0084B4",
            "profile_sidebar_border_color": "C0DEED",
            "profile_sidebar_fill_color": "DDEEF6",
            "profile_text_color": "333333",
            "profile_use_background_image": false,
            "has_extended_profile": false,
            "default_profile": false,
            "default_profile_image": false,
            "following": false,
            "follow_request_sent": false,
            "notifications": false
        },
        "geo": null,
        "coordinates": null,
        "place": null,
        "contributors": null,
        "is_quote_status": false,
        "retweet_count": 4,
        "favorite_count": 5,
        "entities": {
            "hashtags": [],
            "symbols": [],
            "user_mentions": [{
                "screen_name": "JoeMayo",
                "name": "Joe Mayo",
                "id": 15411837,
                "id_str": "15411837",
                "indices": [39, 47]
            }],
            "urls": [],
            "media": [{
                "id": 676817604057497600,
                "id_str": "676817604057497600",
                "indices": [90, 113],
                "media_url": "http:\/\/pbs.twimg.com\/media\/CWSKBmOUAAAqsr2.png",
                "media_url_https": "https:\/\/pbs.twimg.com\/media\/CWSKBmOUAAAqsr2.png",
                "url": "https:\/\/t.co\/CBkJL4KS5Q",
                "display_url": "pic.twitter.com\/CBkJL4KS5Q",
                "expanded_url": "http:\/\/twitter.com\/Dotnetster\/status\/676817605064290306\/photo\/1",
                "type": "photo",
                "sizes": {
                    "large": {
                        "w": 1024,
                        "h": 535,
                        "resize": "fit"
                    },
                    "thumb": {
                        "w": 150,
                        "h": 150,
                        "resize": "crop"
                    },
                    "medium": {
                        "w": 600,
                        "h": 313,
                        "resize": "fit"
                    },
                    "small": {
                        "w": 340,
                        "h": 177,
                        "resize": "fit"
                    }
                }
            }]
        },
        "extended_entities": {
            "media": [{
                "id": 676817604057497600,
                "id_str": "676817604057497600",
                "indices": [90, 113],
                "media_url": "http:\/\/pbs.twimg.com\/media\/CWSKBmOUAAAqsr2.png",
                "media_url_https": "https:\/\/pbs.twimg.com\/media\/CWSKBmOUAAAqsr2.png",
                "url": "https:\/\/t.co\/CBkJL4KS5Q",
                "display_url": "pic.twitter.com\/CBkJL4KS5Q",
                "expanded_url": "http:\/\/twitter.com\/Dotnetster\/status\/676817605064290306\/photo\/1",
                "type": "photo",
                "sizes": {
                    "large": {
                        "w": 1024,
                        "h": 535,
                        "resize": "fit"
                    },
                    "thumb": {
                        "w": 150,
                        "h": 150,
                        "resize": "crop"
                    },
                    "medium": {
                        "w": 600,
                        "h": 313,
                        "resize": "fit"
                    },
                    "small": {
                        "w": 340,
                        "h": 177,
                        "resize": "fit"
                    }
                }
            }]
        },
        "favorited": false,
        "retweeted": false,
        "possibly_sensitive": false,
        "lang": "en"
    },
    "is_quote_status": false,
    "retweet_count": 4,
    "favorite_count": 0,
    "entities": {
        "hashtags": [],
        "symbols": [],
        "user_mentions": [{
            "screen_name": "Dotnetster",
            "name": "Ross McLoughlin",
            "id": 26903787,
            "id_str": "26903787",
            "indices": [3, 14]
        }, {
            "screen_name": "JoeMayo",
            "name": "Joe Mayo",
            "id": 15411837,
            "id_str": "15411837",
            "indices": [55, 63]
        }],
        "urls": [],
        "media": [{
            "id": 676817604057497600,
            "id_str": "676817604057497600",
            "indices": [106, 129],
            "media_url": "http:\/\/pbs.twimg.com\/media\/CWSKBmOUAAAqsr2.png",
            "media_url_https": "https:\/\/pbs.twimg.com\/media\/CWSKBmOUAAAqsr2.png",
            "url": "https:\/\/t.co\/CBkJL4KS5Q",
            "display_url": "pic.twitter.com\/CBkJL4KS5Q",
            "expanded_url": "http:\/\/twitter.com\/Dotnetster\/status\/676817605064290306\/photo\/1",
            "type": "photo",
            "sizes": {
                "large": {
                    "w": 1024,
                    "h": 535,
                    "resize": "fit"
                },
                "thumb": {
                    "w": 150,
                    "h": 150,
                    "resize": "crop"
                },
                "medium": {
                    "w": 600,
                    "h": 313,
                    "resize": "fit"
                },
                "small": {
                    "w": 340,
                    "h": 177,
                    "resize": "fit"
                }
            },
            "source_status_id": 676817605064290306,
            "source_status_id_str": "676817605064290306",
            "source_user_id": 26903787,
            "source_user_id_str": "26903787"
        }]
    },
    "extended_entities": {
        "media": [{
            "id": 676817604057497600,
            "id_str": "676817604057497600",
            "indices": [106, 129],
            "media_url": "http:\/\/pbs.twimg.com\/media\/CWSKBmOUAAAqsr2.png",
            "media_url_https": "https:\/\/pbs.twimg.com\/media\/CWSKBmOUAAAqsr2.png",
            "url": "https:\/\/t.co\/CBkJL4KS5Q",
            "display_url": "pic.twitter.com\/CBkJL4KS5Q",
            "expanded_url": "http:\/\/twitter.com\/Dotnetster\/status\/676817605064290306\/photo\/1",
            "type": "photo",
            "sizes": {
                "large": {
                    "w": 1024,
                    "h": 535,
                    "resize": "fit"
                },
                "thumb": {
                    "w": 150,
                    "h": 150,
                    "resize": "crop"
                },
                "medium": {
                    "w": 600,
                    "h": 313,
                    "resize": "fit"
                },
                "small": {
                    "w": 340,
                    "h": 177,
                    "resize": "fit"
                }
            },
            "source_status_id": 676817605064290306,
            "source_status_id_str": "676817605064290306",
            "source_user_id": 26903787,
            "source_user_id_str": "26903787"
        }]
    },
    "favorited": false,
    "retweeted": false,
    "possibly_sensitive": false,
    "lang": "en"
}

Notice at the bottom of the JSON that retweeted is false, yet retweeted_status clearly has an associated JSON object. On this particular tweet, I did click the Twitter Retweet button, shown here:

https://twitter.com/Dotnetster/status/676817605064290306

Note: You can access the JSON of any query by examining the TwitterContext instance RawResult after the query completes.

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