mlrkey
mlrkey

Reputation: 41

Tweepy - Get Id of retweeted tweet

Does anyone know how this is done? I'm trying to get the id of the original tweet. So if someone retweets something, I want to find what they retweeted. This is what I have to determine what is retweeted or not:

if hasattr(status, 'retweeted_status'): #if not rt'd
        #something
else:                                   #if rt'd
        #something

Upvotes: 1

Views: 1915

Answers (1)

Unni
Unni

Reputation: 5794

The field retweeted_status contains the representation of the original tweet that was retweeted to generate the status object you have with you. So every field that is present in a twitter status object is included as such in the retweeted_status field. Now all you have to do is to get them like

status.retweeted_status.id_str

to get the id of the parent tweet, for instance. Simply modify this accordingly to get whatever field you need from the parent tweet.

Upvotes: 4

Related Questions