API.get_status(ID,include_my_retweet=1) If you specify, current_user_retweet {u'id': xxx, u'id_str': u'xxx'} will be attached to the returned status object. The ID is retweetID, and if you put it in API.destroy_status (ID), RT will be canceled. As an example of use, it looks like this.
undo_retweet.py
status = api.get_status(ID, include_my_retweet=1)
if status.retweeted == True:
api.destroy_status(status.current_user_retweet['id'])
First, except for tweepy's API reference, it looks like the one below. If only the ID is specified in this way, current_user_retweet will not be returned and API.destroy_retweet (id) does not exist, so RT cannot be canceled.
The ID of the status object returned at the time of retweet is retweetID, but once retweet is done, it must be canceled manually and the retweetID must be saved in a txt file. This is very annoying. When I looked it up, I found the following article http://pg-kura.hatenablog.com/entry/20120328/1332949548
It seems to be a PHP (?) Article, but it seems that this can be used as it is with tweepy. In short, looking at the reference, it seems that only id can be specified, but in reality, include_my_retweet can also be specified.
Recommended Posts