I have found this question. However I think this has changed on API version 1.1.
If I use the search/tweets
method, how can I see if the tweet is a RT?
The retweeted_status
property will exist if the received tweet was retweeted, else you will get the AttributeError
error. In the case, you want to get rid of retweeted tweets:
def on_status(self, status):
try:
print "Retweeted ************* \n" + str(status.retweeted_status)
return
except AttributeError:
print "there is no attribut with name retweeted_status"
As everyone else has mentioned, you can check to see if the retweeted_status
property exists in the response subfield for that Tweet.
However, per the current version of the API, every Tweet object has the field retweeted
that stores a boolean value (True or False) that will tell you if a Tweet has been retweeted.
By simply checking the property name
"retweeted_status"
if you does not find then it's not RT.
Make sure your "re-tweet" is not actually a quote of an another tweet. In this case, I had to use the quoted_status
field to get the original tweet, rather than the retweeted_status
one.
Just to add a bit more. (using twitter gem (ruby language))
You can check if its a retweet by checking the tweet and then getting what you need from the retweeted_status hash
t = client.status(#########) #function that obtains tweet based on ID where # = tweet ID
puts t.retweeted_status? # returns true or false
t.retweeted_status # returns the actual hash for that
If it's a retweet, the tweet will contain a property named retweeted_status
. To be complete, retweeted_status
will not appear if the tweet is not a retweet. More info at: Tweets.