Update README.md
This commit is contained in:
parent
923436ede9
commit
22b2a45572
1 changed files with 98 additions and 1 deletions
99
README.md
99
README.md
|
@ -1,2 +1,99 @@
|
||||||
# autofollow-script-for-mastodon
|
# AutoFollow Script for Mastodon
|
||||||
|
|
||||||
|
So, you've decided you're too important to keep track of your followers manually on Mastodon? No worries, this PHP script will handle that tedious task for you. It will automatically ensure you follow back every user who follows you and unfollow those who have the audacity to stop following you. Because, who has time for that, right?
|
||||||
|
|
||||||
|
## Prerequisites
|
||||||
|
|
||||||
|
- PHP installed on your system (because you don't think cutting-edge is overrated)
|
||||||
|
- A Mastodon account with API access (yeah, of course, you have one)
|
||||||
|
- cURL enabled in your PHP installation (because plain ol’ HTTP requests are for mortals)
|
||||||
|
|
||||||
|
## Setup
|
||||||
|
|
||||||
|
1. **Download/Clone the Script**:
|
||||||
|
Get your hands on this masterpiece by either downloading or cloning the script to your chosen directory on your server or local machine.
|
||||||
|
|
||||||
|
2. **Get Your Access Token**:
|
||||||
|
- Log in to your Mastodon account like a pro.
|
||||||
|
- Navigate to Preferences -> Development -> Your applications.
|
||||||
|
- Create a new application (easy peasy) and copy that fancy access token.
|
||||||
|
|
||||||
|
3. **Edit the Script**:
|
||||||
|
Now, for the fun part—replace the placeholder values in `autofollow.php`:
|
||||||
|
|
||||||
|
```php
|
||||||
|
$accessToken = 'xxxx-xxxx-xxxx-xxxx'; // Because <Insert your paranoia here>
|
||||||
|
$baseUrl = 'https://corteximplant.com'; // Change this unless you’re from the future
|
||||||
|
```
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
1. **Execute the Script**:
|
||||||
|
Run the script using PHP from the command line. Prepare to be amazed:
|
||||||
|
```sh
|
||||||
|
php autofollow.php
|
||||||
|
```
|
||||||
|
|
||||||
|
2. **Output**:
|
||||||
|
The script will proudly display the accounts it follows and unfollows:
|
||||||
|
```plaintext
|
||||||
|
Following user: user1
|
||||||
|
Following user: user2
|
||||||
|
Unfollowing user: user3
|
||||||
|
```
|
||||||
|
|
||||||
|
## Automate Using a Cron Job
|
||||||
|
|
||||||
|
Because doing it manually is so last century. Here's how you can set up a cron job to let this bad boy run at regular intervals:
|
||||||
|
|
||||||
|
1. **Open Crontab**:
|
||||||
|
Open your crontab file for editing. If you’ve never done this before, welcome to the 21st century:
|
||||||
|
```sh
|
||||||
|
crontab -e
|
||||||
|
```
|
||||||
|
|
||||||
|
2. **Add Cron Job**:
|
||||||
|
Add the following line to run the script every hour. Because who doesn’t want a 24/7 personal assistant?
|
||||||
|
```sh
|
||||||
|
0 * * * * /usr/bin/php /path/to/autofollow.php
|
||||||
|
```
|
||||||
|
|
||||||
|
Make sure the PHP binary location (`/usr/bin/php`) and the path to your script (`/path/to/autofollow.php`) are spot on.
|
||||||
|
|
||||||
|
3. **Save and Exit**:
|
||||||
|
Save the crontab file and get ready to enjoy your newfound free time. The script will now run hourly as instructed.
|
||||||
|
|
||||||
|
## Script Functions
|
||||||
|
|
||||||
|
In case you're curious (or just enjoy reading code), here's what each function does:
|
||||||
|
|
||||||
|
### 1. `getFollowers($baseUrl, $accessToken)`
|
||||||
|
Fetches the list of followers for the authenticated user. Because knowing who adores you is crucial.
|
||||||
|
|
||||||
|
### 2. `getFollowing($baseUrl, $accessToken)`
|
||||||
|
Fetches the list of users that you're currently following. Gotta keep tabs on your social obligations.
|
||||||
|
|
||||||
|
### 3. `followUser($baseUrl, $accessToken, $userId)`
|
||||||
|
Follows a user given their user ID. Because that’s what polite digital citizens do.
|
||||||
|
|
||||||
|
### 4. `unfollowUser($baseUrl, $accessToken, $userId)`
|
||||||
|
Unfollows a user given their user ID. No hard feelings, right?
|
||||||
|
|
||||||
|
### 5. **Core Logic**:
|
||||||
|
The script’s backbone that tirelessly syncs your followers and followings. Thank it later.
|
||||||
|
|
||||||
|
## Important Notes
|
||||||
|
|
||||||
|
- Use this script responsibly. Don’t be that spammy person we all secretly loathe.
|
||||||
|
- Keep your access token secure. Seriously, don’t wave it around.
|
||||||
|
- Feel free to tweak this script to suit your grand vision. It’s a starting point, not the final destination.
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
Open-source magic. Use it, transform it, and share the love as per the GNU AFFERO GENERAL PUBLIC LICENSE. Check out the [LICENSE](LICENSE) file for more details. Or not—your call.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
For any issues, blame your Internet connection. Or, alternatively, open an issue or a pull request on the CYBERWARE repository if you're feeling cooperative.
|
||||||
|
|
||||||
|
Happy automating! 🚀
|
Loading…
Reference in a new issue