I was trying to syndicate from my website so that the post on Mastodon would credit my website for the post and link back to my homepage as the application that made the post. You’ll notice at the bottom of the post there’s the post date and a globe icon, which indicates the post is public, followed by my website name ‘BoffoSocko.com’ and details about replies, reposts, and favorites.
I assuredly won’t release a public plugin for WordPress that does this. But since some have asked how I did it, I thought I’d share some of the internals of a few WordPress plugins that one can quickly modify to achieve the same thing.
That I can currently see, there are three plugins in the repository that will allow one to syndicate content to a variety of Mastodon instances. They are Mastodon Autopost, Mastodon Auto Share, and Share on Mastodon. The first two are closely related and essentially replicate the same codebase.
Similar to using Twitter’s API to crosspost, Mastodon is looking for two bits of information when an application is registered: a client name and a website URL.
Mastodon Autopost and Mastodon Auto Share, both have a file called client.php
which define these two variables.
public function register_app($redirect_uri) { $response = $this->_post('/api/v1/apps', array( 'client_name' => 'Mastodon Share for WordPress', 'redirect_uris' => $redirect_uri, 'scopes' => 'write:statuses write:media read:accounts', 'website' => $this->instance_url ));
You can edit this file with a text editor to change the 'client_name'
from 'Mastodon Share for WordPress'
to 'Anything You Want'
. If you’re in a joking mood, maybe change it to 'Twitter'
?
To change the URL so that the link on the client_name
directs to your website, you’ll want to change the line 'website' => $this->instance_url
.
In particular change $this->instance_url
to 'https://example.com'
where example.com would be your website. I’ll note that $this->instance_url
on this line in the original plugin is a bug. If left alone, it points the URL to your home Mastodon instance instead of to the more logical https://wordpress.org/plugins/autopost-to-mastodon/
where the plugin lives.
If you prefer using Jan Boddez‘ excellent plugin, you’ll want to do something similar, except in that case you’ll want to change a file named class-options-handler.php
in the includes
folder.
Here you’ll want something like:
'client_name' => __( 'Example.com' ),
But note that Boddez doesn’t have a similar bug, so the website line
'website' => home_url(),
is already correctly defined so that your website will automatically be linked without any changes to it.
If you’re already using one of these plugins and manually modify them, note that you’ll probably need to re-authorize the plugin so that the changes propagate.
cool, if you are at #rC3 :
currently pixeling rooms 🙂
– come by …
Thank you for sharing Chris. I was wondering what you were doing. Might be time to dig back in again.
Thank you for sharing this, Chris. I’m also interested in finding a way to post on Mastodon and post to my WordPress site.
Syndicated copies:
I sketched out two methods earlier today for someone in the comments on another post: https://boffosocko.com/2022/04/25/55804148/#comment-374484
Another method might be to use PESOS and post to Mastodon directly and use something like IFTTT to reverse syndicate to your site, though this would make it harder to backfeed replies from Brid.gy. See: https://boffosocko.com/2020/01/21/using-ifttt-to-syndicate-pesos-content-from-social-services-to-wordpress-using-micropub/
I’m liking this the old fashioned way, saying I like it. Not sure if it’s in these plugins or the way mastodon gets the featured image, but I found none of these plugins (nor ActivityPub) send a featured images alt text when it’s in the WP library.
I found it easy to set up IFTTT to auto post triggered by RSS and a web hook.
I’m looking for a good php client to do API calls to Mastofon to get replies to a specific account (that I can authorize).
This is some fun time to be tinkering
I’ve been having some issues with it for the past week or so, likely as the result of the upgrade to Mastodon 4.0 and the increases in traffic, but the best/only method for syndicating from my site into a separate Mastodon instance that also includes alt-text for photos is Brid.gy (see: https://brid.gy/about#picture). If set up in conjunction with Webmention plugin (and optionally the Semantic Linkbacks plugin), Brid.gy will also feed back replies/likes/boosts from Mastodon back to your website as comments. If you do use Brid.gy to syndicate/publish into Mastodon, you’re going to want some basic proper microformats support for your theme. I’m happy to help describe this in a crash course if you don’t have the expertise on microformats, though I know you’ve got the theming background to pull it off. (See also: https://indieweb.org/WordPress/Themes#Microformats)
Two other options here are:
* to use https://fed.brid.gy/ which will go a long way towards making your WordPress site look like an ActivityPub/Fediverse instance, or
* use Matthias Pfefferle’s ActivityPub, Webfinger, and NodeInfo plugins which will give you a lot of the same functionality (this is what I’ve opted for making my whole site followable as @chrisaldrich@boffosocko.com). This option also automatically adds alt-text to photos if they have them in your own website.
I haven’t compared the two options in over 18 months, but I think Pfefferle’s may give stronger/broader support presently. The thing these don’t give you is a reader interface for subscribing/reading/direct interactions, but that can be done reasonably with a feed reader, or even better with a social reader. I’ve outlined some of this functionality in the past: https://boffosocko.com/2021/04/26/a-twitter-of-our-own-at-oerxdomains-2021-conference/