Skip to content

Delete all tweets and retweets from your account, delete all tweets posted before the last X days.

License

Notifications You must be signed in to change notification settings

cachuco/Delete-tweets-script---Google-apps-script

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Delete tweets script with twitter file - Google Apps Script

Delete all tweets and retweets from your account or delete all tweets posted before the last X days.

The script reads the twitter file and deletes one by one starting with the oldest tweet. It is possible to set a number of days (MAX_AGE_IN_DAYS) for which there are no more tweets, for example: if MAX_AGE_IN_DAYS = 30, the script will not delete the tweets published in the last 30 days. It is also possible to define a specific ID that we do not want to eliminate, for example, if we put the ID of our first tweet in the SAVE_THIS_TWEET variable, it will not be deleted.

Google Apps Script has a limitation on the script runtime of 6 min, so it is advisable to schedule a script execution automatically every 15 minutes so as not to exceed the limits of the Twitter API requests. (Running the script every 10 minutes 6,000 tweets per hour are deleted.)

Prerequisites

Get your Twitter archive

  1. Open your account page.
  2. Click 'Your Twitter archive', and a link to your archive will arrive per email.
  3. Follow the link in the email to download the archive.
  4. Unpack the archive.

Create new twitter app and configure API

  1. Open Twitter's Application Management, and create a new Twitter app.
  2. Set the permissions of your app to Read and Write.
  3. Set the required environment variables

Create new Google Apps Script project Google Apps Script

Copy deleteTweets.gs file in you GAS project and configure variables

Copy your TWEET.JS file from twiiter archive to your Google Drive and save the file ID

Execute script and enjoy your life

Use

Configure the following variables:

var TWITTER_USER = 'YOUR TWITTER USER NAME';
var MAX_AGE_IN_DAYS = 30;
var SAVE_THIS_TWEET = 0;
var CONSUMER_KEY = 'YOUR CONSUMER KEY';
var CONSUMER_SECRET = 'YOUR CONSUMER CONSUMER_SECRET';
var ACCESS_TOKEN = 'YOUR ACCESS TOKEN';
var ACCESS_SECRET = 'YOUR ACCESS SECRET';
var TWEET_JS_FILE = 'TWEET.JS FILE ID SAVED IN YOUR GOOGLE DRIVE';
variable description
TWITTER_USER Twitter username (exclude @)
MAX_AGE_IN_DAYS tweets with a date greater than this number, will be deleted
SAVE_THIS_TWEET this ID won't be deleted
CONSUMER_KEY The Consumer Key from your Twitter App
CONSUMER_SECRET The Consumer Secret from your Twitter App
ACCESS_TOKEN The Access Token from your Twitter App
ACCESS_SECRET The Access Secret from your Twitter App
TWEETS_JS_FILE ID from tweet.js file in your Google Drive

Versioning

1.1.0

License

See the LICENSE file for license rights and limitations (GPL-3).

About

Delete all tweets and retweets from your account, delete all tweets posted before the last X days.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published