No description
Find a file
2024-08-16 14:49:33 +00:00
autofollow.php Add autofollow.php 2024-08-16 14:49:33 +00:00
LICENSE Initial commit 2024-08-16 14:48:08 +00:00
README.md Update README.md 2024-08-16 14:48:49 +00:00

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:

    $accessToken = 'xxxx-xxxx-xxxx-xxxx'; // Because <Insert your paranoia here>
    $baseUrl = 'https://corteximplant.com'; // Change this unless youre from the future
    

Usage

  1. Execute the Script: Run the script using PHP from the command line. Prepare to be amazed:

    php autofollow.php
    
  2. Output: The script will proudly display the accounts it follows and unfollows:

    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 youve never done this before, welcome to the 21st century:

    crontab -e
    
  2. Add Cron Job: Add the following line to run the script every hour. Because who doesnt want a 24/7 personal assistant?

    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 thats 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 scripts backbone that tirelessly syncs your followers and followings. Thank it later.

Important Notes

  • Use this script responsibly. Dont be that spammy person we all secretly loathe.
  • Keep your access token secure. Seriously, dont wave it around.
  • Feel free to tweak this script to suit your grand vision. Its 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 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! 🚀