Skip to content

Sending Webmention Notifications to My Social Reader

I’ve written about Aperture before, and how I’ve added some experimental features to it, and about wanting to write my own, simpler Microsub server. (For those not in the know, a Microsub server is a sort of feed aggregator, and more.)

Anyway, I’m sitting down, pondering my own implementation, right, and how come channels don’t simply behave like categories in other readers, and why on Earth I’d need a Notifications channel (which can be hidden, but not removed). And I’m learning channels are modeled after Slack channels, and TweetDeck columns, rather than existing RSS readers’ categories, and it all makes sense.

And I’m starting to see how the Notifications channel is especially useful in combination with (Aperture’s) channel API tokens, which allow users to directly push entries to the channel in question. And decide to do so for every new comment—or rather, webmention—on this blog.

Here’s how it works:

add_action( 'wp_insert_comment', function( $comment_id, $comment ) {
    esc_url_raw( '' ), // My Aperture instance's Micropub endpoint.
      'headers' => array(
        'Authorization' => 'Bearer <my-secret-API-token>', // Generated using the New API Key button in Aperture.
        'Content-type'  => 'application/x-www-form-urlencoded',
      'body'    => array(
        'h'       => 'entry',
        'content' => 'Received a new comment! Have a look: ' . esc_url_raw( admin_url( 'comment.php' ) . '?action=approve&c=' . $comment_id . '#wpbody-content' ),
      'timeout' => 15,
}, 10, 2 );

My Notifications channel now sort of acts like Twitter’s (or Mastodon’s) Notifications tab, and I no longer have to log into WP Admin to find out about new comments—I’ve long disabled email notifications for just about everything. Once more, my social reader’s one step closer to becoming my “new home on the internet”!

Aside: I’m using a Linux cron job to trigger WordPress’s cron script every couple minutes, causing actions of this kind to nearly always run in the background.