I realised I had an ical file of all my appointments from the period I used Google Calendar from January 2008 when I started as an independent consultant, until February 2020 when I switched to the calendar in my company’s NextCloud.
I never search through that file even though I sometimes wonder what I did at a certain moment in that period. After a nudge by Martijn Aslander who wrote on a community platform we both frequent about back filling his daily activities into Obisidian for instance based on his photos of a day through the years in his archive, I thought to import that ical file and turn it into day logs listing my appointments for a date.

I tried to find some ready made parsers or libraries I could use in PHP, but most I could find is aimed at importing a live calendar rather than an archived file, and none of them were aimed at creating an output of that file in a different format. Looking at the ical file I realised that making my own simple parser should be easy enough.

I write a small PHP script that reads the ical file line by line until it finds one that says BEGIN:VEVENT. Then it reads the lines until it finds the closing line END:VEVENT. It then interprets the information between those lines, lifting out the date, location, name and description, while ignoring any other information.
After each event it finds, it writes to a file ‘Daylog [date].md’ in a folder ./year/month (creating the file or appending the event as a new line if the file exists). It uses the format I use for my current Day logs.
Let it repeat until it processed all 4.714 events in my calendar from 2008 to 2020.

A screenshot of all the folders with Daylogs created from 2008-2020

Screenshot of the newly created Daylog for 20 February 2008, based on the appointments I had that day, taken from the calendar archive. This one mentions a preparatory meeting for the open GovCamp I helped organise that year in June, which kicked off my work in open data since then.

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.link, ton_entry.author, ton_entry.title, ton_entrytag.id_tag, uncompress(ton_entry.content_bin) as content FROM ton_entry JOIN ton_entrytag ON ton_entry.id=ton_entrytag.id_entry

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.