Don't forget to chmod the script file as executable. (ex: $ chmod 0755 delete_toot.php)
Run the script once and it will create a JSON file for user settings.
$ php delete_toot.php
Then edit the JSON file and change the values below.
scheme -> ex. https
host -> ex. qiitadon.com
access_token -> Get it from your instance's settings.
Optional:
id_skip -> Set toot IDs to skip deleteing.
time_sleep -> Must be more than 1. The bigger the slower.
id_account -> Leave it blank then the script will auto fill.
Run the script again and wait until it's done.
Note1 : To run it backgroundsee below.
Note2 : Don't forget to delete 'nohup.out' file after finish.
How do I get the access token?
Open your Mastodon account settings.
Go to "</> Development" setting and open "Your applications".
Create "NEW APPLICATION" with the settings below.
Application name : Any name you want and easy to notice.
Application website : Any web site, may be this GitHub page.
Redirect URI : Leave it as is.
Scopes : Check all.
Note: Don't forget to delete this application entry after use. (For sureness)
Why it's slow?
This script deletes 1 toot/second by default because of the Mastodon's access limitation.
Since there's an access time limitation to use the API and if you request more than 300 authorized requests in 5 minutes ( 1 authorized request per second) / account, you'll get a "Too many request" error. Therefore this script is slow.
$ # Check the current PID to compare
$ ps
$
$ # Run the script in background then press Ctrl+c to exit
$ nohup php ./delete_toot.php &
$
$ # Recheck the PID to see if the script is running
$ ps
$
$ # See the progress to check
$ tail -f nohup.out
Operation environment tested
Topic
Content
Confirmation date
2018/03/12
Mastodon
v2.1.0
OS
macOS High Sierra(OSX 10.13.3)
Machine
MacBookPro(Retina, 13-inch, Early 2015)
$ php -v
PHP 7.1.8 (cli) (built: Aug 7 2017 15:02:45) ( NTS ) Copyright (c) 1997-2017 The PHP Group Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
$ bash --version
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin17) Copyright (C) 2007 Free Software Foundation, Inc.
请发表评论