How to cancel RT with tweepy

First conclusion

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'])

Detailed overview

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. Image1

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

How to cancel RT with tweepy
How to selectively delete past tweets with Tweepy
How to update with SQLAlchemy?
How to cast with Theano
How to Alter with SQLAlchemy?
How to separate strings with','
How to RDP with Fedora31
How to Delete with SQLAlchemy?
Python: How to use async with
How to use virtualenv with PowerShell
How to deal with imbalanced data
How to install python-pip with ubuntu20.04LTS
How to deal with imbalanced data
How to get started with Scrapy
How to get started with Python
How to deal with DistributionNotFound errors
How to get started with Django
How to Data Augmentation with PyTorch
How to use FTP with Python
How to calculate date with python
How to install mysql-connector with pip3
How to INNER JOIN with SQLAlchemy
How to install Anaconda with pyenv
How to authenticate with Django Part 2
How to authenticate with Django Part 3
How to do arithmetic with Django template
[Blender] How to set shape_key with script
How to title multiple figures with matplotlib
How to get parent id with sqlalchemy
How to add a package with PyCharm
How to install DLIB with 2020 / CUDA enabled
How to use ManyToManyField with Django's Admin
How to use OpenVPN with Ubuntu 18.04.3 LTS
How to use Cmder with PyCharm (Windows)
How to use Tweepy ~ Part 1 ~ [Getting Tweet]
How to prevent package updates with apt
How to work with BigQuery in Python
Get replies to specific tweets with tweepy
How to use Ass / Alembic with HtoA
How to deal with enum compatibility errors
How to use Japanese with NLTK plot
How to do portmanteau test with python
How to search Google Drive with Google Colaboratory
How to display python Japanese with lolipop
How to download youtube videos with youtube-dl
How to use jupyter notebook with ABCI
How to power off Linux with Ultra96-V2
"How to pass PATH" to learn with homebrew
How to scrape websites created with SPA
How to use CUT command (with sample)
How to enter Japanese with Python curses
[Python] How to deal with module errors
How to install zsh (with .zshrc customization)
How to read problem data with paiza
How to use SQLAlchemy / Connect with aiomysql
How to get started with laravel (Linux)
How to group volumes together with LVM
How to install python3 with docker centos
How to use JDBC driver with Redash
How to upload with Heroku, Flask, Python, Git (4)
How to deal with memory leaks in matplotlib.pyplot