Feed Me

How to post to Mastodon using your personal web blog's built-in RSS feed

  • From Dave:

I have an app running on this server called FeedToMasto, which apparently is watching that feed. It's been chugging away like an abandoned science fiction robot, seeing if I posted anything to my linkblog, and forwarding it to Mastodon if I have. Hello my robot friend, you were forgotten but still appreciated. It's open source, of course, and appears to be well-documented. If you're looking for example code that reads feeds and pushed the result to interesting places, this is for you.

Dave to the rescue!

Reference: http://scripting.com/2025/07/15.html#a115347

This worked:

I use the Pelican [1] static web site generator for this website, and it has an automatic RSS (atom) feed generator for all articles. The following method lets me create posts on my Pelican site, with very little readers, and automatically post a link to new articles on fostodon.org, which has a larger audience.

Install node and npm via the Node Version Manager (nvm):

(I removed the apt version of node and npm first)

$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh > nvm-install.sh
$ bash -x ./nvm-install.sh
$ nvm install node
$ nvm install npm
$ npm install request
$ npm install websocket

Install feedToMasto:

1. $ git clone https://github.com/scripting/feedToMasto
2. $ cd feedToMasto 
3. $ git clone https://github.com/scripting/reallysimple
4. $ git clone https://github.com/scripting/utils
5. Change config.json (hints)
   <https://github.com/scripting/feedToMasto/blob/main/README.md>
   <https://github.com/scripting/feedToMasto/issues/1>

Step 5 requires you to log into your own Mastodon Instance [2] (see below) and replace all of Dave's names with your own, in file -> config.json.

Backup config.json before editing

  • Using the info from your Mastodon Instance [2], change:
urlMastodonServer
clientKey
clientSecret
accessToken
  • Replace the json feed array with your own.

This is where I put my github.io pages atom.xml feed url. https://dfcsoftware.github.io/linux-in-house/feeds/writing.atom.xml

  • By default no existing posts will be processed

Set flOnlyPostNewItems to false to see all your existing posts on the first run!

  • delete bluesky and wordpress if you don't want that.

By default they are disabled, so you can leave them.

Run it:

$ node feedToMasto.js

It will echo your config.json, and if file stats.json does not exits, create it. Then it polls your feed array urls for new posts...

When I post a new item to my site, Pelican [1] updates the atom feed, and feedToMasto.js posts a link to the new article on Mastodon or bluesky, or wordpress, if enabled.

Just put node feedToMasto.js in an /etc/init.d/rc.x or systemd daemon runner and voila' abandoned science fiction robot

Thanks Dave!
-- Don Cohoon

Reference:

  1. https://getpelican.com/

  2. Get Mastodon info

On your Mastodon account

Click on Preferences, in the right margin.

Click on Development in the left margin.

Click on the New application button in the upper right corner.

You should see a form that looks like this.

feedToMastodon-newApplicationScreen.png

We're going to fill in the form.

Application name -- anything you like, perhaps feedToMasto.

Application website -- anything you like.

Redirect URI -- leave it as-is.

In the Scopes section do the following.

Uncheck read.

Check read:accounts.

Uncheck write.

Check write:statuses.

Uncheck follow.

When you're done the Scopes section should look like this.

feedToMastodon-checkboxesScreen.png

Finally click the Submit button at the bottom of the page.

You should then see a list of your applications, with this new app on the list.

Click on the name of the new app to bring up a screen with various numeric strings you'll add to config.json.

--

____          
|  _ \  ___  _ __  
| | | |/ _ \| '_ \ 
| |_| | (_) | | | |
|____/ \___/|_| |_|                             

¯\_(ツ)_/¯

links

social