php mastodon rss to bot stateless: GitHub File Free Download

PHP Feed-to-Bot Tool for Mastodon

A tool for creating bots for Mastodon which read RSS/Atom feeds.


  • Multiple bots from one script
  • Multiple feeds per bot
  • Supports (valid) RSS and Atom
  • Stateless: in the sense that it does not maintain a cache of which RSS posts have been converted to toots.

Currently running the RFI Bot on


Requires PHP 7.0

You will need a cert file to run Guzzle.

You will also need to set the timezone of your computer via the php.ini date.timezone setting.

Load Dependencies

Dependencies are loaded via Composer

composer install

It uses the following dependencies:


This code takes care of running the 3rd party application which handles the bots.

You will need to copy /configurations/APP.example.json to /configurations/APP.json.

In /configurations/APP.json change the name property to a custom name.

Bot Configuration

You will first need to manually make the account on the Mastodon instance of your choice with an email, password and username.

The file /configurations/example.json is an example of a bot configuration. Create a new JSON in the /configurations/ folder and name it for your bot.

	"instance" : "", //like ''

	"username" : "my_username",            //username for your bot's account, not display name
                                             //not used at this point

	"email" : "",  //email for your bot's login

	"password" : "realpassword",           //password for your bot's login

	"hashtags" : ["all"],                  //array of strings that you want as 
                                             //hashtags (#) in each toot
                                             //do not add '#'

	"feeds" : [{                           //array of feeds for this bot

		"type" : "rss",                    //type of feed, rss or atom

		"url" : "",
                                           //url to feed

		"hashtags" : ["cats"]              //hashtags for every toot from this feed
		"type" : "rss",
		"url" : "",
		"hashtags" : ["music"]
		"type" : "atom",
		"url" : "",
		"hashtags" : ["mood"]

Create a separate configuration file for each bot you wish to run.



If your configuration file is called my_rss.json, then the RSS items can be posted/updated with:

php /path/to/php-mastodon-rss-to-bot-stateless/index.php my_rss

Please note the lack of ‘.json’ in the parameter.

To keep the application ‘stateless’ (see top), the tool works based off of timestamps. The tool will check the timestamp of the latest toot and get all Feed items after that timestamp and posts them.

Obviously, this has the potential to not be as accurate as a bot with a cache, but I’m too lazy to build one. If your feed has items added every minute (hopefully unlikely), then this tool may miss an item or two along the way.

If the bot is new and has no posts, it will only post the most recent feed item, not the entire feed.


In order to have a bot that updates regularly, you will need to schedule the above PHP call with a Cron task or a Scheduled Task depending on your system.

You will need to schedule separate tasks for each bot/config.


If you need to disable the tool for a while (system maintenance, etc), but you don’t want the bot to flood Mastodon with a bunch of belated posts when it starts up again, you can just make a post directly to the bot via the Mastodon interface and then start the scheduled task again. The new post will make sure the most recent timestamp in the Toot timeline is up to date.


  • Create config class to validate configurations
  • Add utility class and PHPUnit for long term stability
  • Get toot length by instance
  • Replace strlen with more reliable function
  • Extend to any iterable, fetchable, timestamped resource

Go to GitHub File