After creating a Micropub client, so that I can post automatically to this site from a script, I decided to make the next step: creating my own Microsub client. What that is, and why I want it I’ll discusse some other time. But quickly after beginning that I realised a key first step needed to be solved first: getting the right authorisation to access my site.

My micropub client also requires that authorisation, but I circumvented doing that myself by using Jamie Tanna’s online tool to create the right access token to gain entry to my site. However, Jamie’s tool sets the scope of the permissions to ‘draft’, meaning you can save new posts as draft. That was fine for micropub, but isn’t useful for microsub.

For microsub I need a different scope, read and follow at first. So instead of starting to build a Microsub client, I first needed to create something to get the right access tokens. Luckily somewhere at the end of the Microsub documentation there’s a summary of the steps you need to take, and once I read that I could imagine a solution, and could recognise the different steps involved. I sketched them out for myself:

I then started to code each of those steps in PHP. In the end I needed about 30 lines of code.
It’s not a fancy script, just one for personal use, so it needs a bit of cleaning before I can share it.

The 4 steps I coded were:

  • Create a URL of the IndieAuth endpoint listed in the site to visit, that contains various pieces of information
  • Make the script able to receive the answer to that at the given redirect_uri:
    The returned status ensures that the response belongs to the request you sent. The code is what you need to use for the next step.
  • For the next step you send a POST request (basically it’s sending in a webform) to the Token endpoint provided by the site, which contains the code you received, grant_type with the value authorization_code, the same client_id you sent earlier, and again a redirect_uri where to receive the answer. That last one can be different form before but must be on the same domain.
  • What you get back is some JSON data that contains the access token. For each interaction you have with the site after this step you use that access token to get access to the site.

Where the notion of authorising myself with some website doing some digital variation of a multistage secret handshake for a long time has seemed daunting to me to create from scratch, once I was able to see the different building blocks it became simpler: each of those building blocks, visiting a URL, reading a response, sending in a webform, and reading JSON data I had written before, so I had some PHP code to re-use.

I am writing a PHP script to talk to my website’s Micropub endpoint. When I had first recycled the PHP script I use to write my Booklists, I ran into an error concerning the HTTPS encryption of traffic to my website:

SSL operation failed with code 1. OpenSSL Error messages:
error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed

For my booklists I had initially pseudo solved it by approaching my server side script in HTTP, not HTTPS. That is not an option when talking to my WordPress site though.

Jan Boddez helpfully gave a few pointers towards potential solutions. I assumed that the issue was that the webserver stack (MAMP PRO) had no access to the certificates it needed to talk to my website.

I downloaded the Mozilla CA bundle as .pem file, and for good measure also the one for my own website, as described here. I added the contents of the .pem file for my own site to the CA bundle at the end (.pem files are text files and you can paste all .pem files together)

At first I added a line in php.ini (be aware that MAMP has many PHP versions installed, which all have their own php.ini file, so make sure to edit the right one).

curl.cainfo = /path/cacert.pem
openssl.cafile= /path/cacert.pem

The fist one definitely wasn’t going to help, as I’m not using curl to send my webrequest, but added for good measure. The other one didn’t help either.

Then I came across a PHP function that could show me which certificates the script was trying to use:


That told me that MAMP is looking in the folder Applications/MAMP/Library/OpenSSL/certs/ in which the cacert.pem file was an outdated Mozilla CA bundle. I replaced it with the one I had downloaded and had added my own site’s file to.

That worked. My script is now able to talk to my website’s Micropub end point and create a post on my site. However the content of the post is missing, so now the next step is ensuring I am posting to my site in the right format. But the crucial first hurdle is taken: contact!

I am working on following somewhat in Peter’s footsteps. He has his FreshRSS reader connected to his weblog, for everything he ‘stars’ in his feed reader. Those get posted to his ‘favourites’ stream, and send webmentions so they end up as ‘likes’ underneath the original posts. See Peter’s description on his blog.

My plans are a bit more ambitious, an ambition that may yet well bump into the limtis of my php / mysql capabilities.

I want to be able to mark articles in the feed reader for three things: bookmarking, favouriting, and replies. Then I want to add two pieces of content, and post that to my site.

When I favourite something on my blog, I basically always add 2 things when posting it: a rationale for why I like something, and a quote from the original article that meant something to me. See the image below, a screenshot of a ‘favourite’ I marked earlier this month.

That post is made of a short template that I now activate when in my blog’s editor with a hotkey (using AlfredApp) that creates the star, and has a place for the URL, title and author, plus my own motivation for posting, and a quote with the author’s name repeated.
Favourites, bookmarks and replies follow the same template. The only difference is the symbol shown, and the microformat used to signal to the original article what sort of webmention I’m sending their way (so they know how to treat it, e.g. as a like or as a comment/reply)

Peter’s example of favouriting by starring leads to setting a boolean field in the content table itself of the database.
FreshRSS lacks three distinct ‘starring’ buttons, but I can easily add labels to a posting. Those labels are stored in a separate table from the feed articles, unlike when starring.

The first step to take then is to gain access to the postings I mark for follow-up during feed reading. I’ve used the following SQL query:

SELECT,, ton_entry.title, ton_entrytag.id_tag, uncompress(ton_entry.content_bin) as content FROM ton_entry JOIN ton_entrytag ON

The two key differences with Peter’s SQL statement are, the JOIN part, and the uncompress part. The JOIN statement combines the table that knows what labels I applied with the table that contains all articles, and selects only those where an article ID is in both tables, resulting in a list of the articles I applied labels to. Because in a later step I want to select a quote from the source article the SQL statement also grabs the content of an article. That content is stored as a compressed binary blob (yes, blob is its official name) in the database. Using ‘uncompress’ makes the content blob human readable again, and the ‘as content’ bit puts it in a variable called content.

The next step is allowing me to provide my remarks and select a quote through a form, and the third step to add all that in to the right template based on the label (favourite, bookmark, reply), after which I need to put it into my WordPress install in the right categories and publish it.

I made a tiny tool for myself today, to make it easier to display both HTML and PHP code in this site (if you just input it as is it will get filtered, as it would be unsafe otherwise)

It’s a small webform that lives as a shortcut in my browser bar:

Which calls itself when submitted, and if there is some input it will encode it by calling the PHP function htmlentities twice (otherwise it would just show the right output, but not what is needed to get that output). The result is shown above the form. Maybe I’ll add a step to put it on the clipboard instead. That would save another step. Currently I run it on an internet accessible webserver, I will likely move it to the webserver I run locally on my laptop Moved it my laptop’s local webserver (making it both safer, and independent from having internet access).

<?php echo "<pre>".htmlentities(htmlentities($_POST["input_tekst"], ENT_QUOTES))."</pre>"; ?>

This makes it possible to document code changes much better in my site. Such as my recent language adaptations.

The code snippet above has of course been made with this form.

I use the WP Plugin Post Kinds here, which lets me blog things like Replies, Likes, etc. This plugin has a setting that determines the order in which my own remarks with a Reply or Like and the thing I am replying to or liking are shown.

The default order is [the thing I respond to] [my response], but here in this blog I have changed that, because I like to have my own response first. This ensures for instance that my own words, and not someone else’s get posted to Twitter if I share my post directly to Twitter.

This setting does not change the way the same blogpost gets added to the RSS feed. This means that my regular readers do not get the content of a posting as I intend it, which is in the same order as a website visitor.
In addition it causes anything that consumes my feed, such as my account to show the post I am responding to first (someone else’s words) and not my remarks. Below in three images is how that looks in practice:

The old version: the order is as I want it on the site.

The old version: the order is reversed for the same item in my feed posts from my feed, and therefore shows not my words first but the words I’m reacting to, which makes them appear as if they are my words

I figured out where in the plugin files (in class-kind-view.php) the feed gets created and how it is different from how the posting is created for the site. Then I added the conditional code from the latter to the former. This works on my site, as shown by the following three images:

Testing the new code: on my site the item is in the right order

In the RSS feed, the content of the item is now in the right order too

And the right order now shows up in, showing my own words first

Then I tried to let the creator of the WP Plugin know I made this change, through a Pull Request on GitHub. I’v never done this before. It’s basically a message ‘I changed this file here’ which the original creator can then adopt in the original code. Making that message meant engaging with concepts such as forks, branches, commits and then the Pull Request. I think I pulled if off, but I will only know when David Shanske, who makes Post Kinds indeed incorporates it in the plugin.

Hoping I’ve submitted my first ever PR the right way