Thanks to everyone who helped me test webmentions that I hacked together at Indie Web Camp last weekend.
Let me explain what web mentions are all about…
Basically, it’s an equivalent to pingback. Let’s say I write something here on adactio.com. Suppose that prompts you to write something in response on your own site. A web mention is a way for you to let me know that your response exists.
If you look in the head
of any of my journal posts, you’ll see this link
element:
<link rel="webmention" href="http://adactio.com/webmention.php" />
That’s my web mention endpoint: http://adactio.com/webmention.php …it’s kind of like a webhook: a URL that’s intended to be hit by machines rather than people. So when you publish your response to my post, you ping that URL with a POST request that sends two parameters:
target
: the URL of my post andsource
: the URL of your response.
Ideally your own CMS or blogging system would take care of doing the pinging, but until that’s more widely implemented, I’m providing this form at the end of each of my posts:
Either way, once you ping my web mention endpoint—discoverable through that link rel="webmention"
—with those two parameters, I just need to confirm that your post does indeed contain a link to my post—by making a cURL request and parsing your source—and then I return a server response of 202 (Accepted).
Here’s the code for a minimum viable web mention in PHP.
That’s as far as I got at Indie Web Camp but it was enough for me to start collecting responses to posts.
The next step is to do something with the responses. After all, I’ve already got the source of each response from those cURL requests.
Barnaby has a written a nice straightforward microformats parser in PHP. I’m using that to check the cURLed source for any responses that have been marked up using h-entry. That’s one of the microformats 2 vocabularies—a much simpler way of writing structured content with microformats.
Aaron, Amber, and Barnaby all sent responses that were marked up with h-entry so now their responses appear in full.
So there you have it. Comments are now open on every journal post on adactio.com …the only catch is that you have to write the comment on your own site. And if you want the content of your post to appear here (instead of just a link) then update your blog post template to include a handful of h-entry classes.
Feel free to use this post as a test. Mark up your blog with h-entry, write a post that links to this URL, and enter the URL of your post in the form below.
# Liked by Chris Perry on Thursday, May 26th, 2016 at 7:31pm
# Liked by Simon Knox on Monday, May 30th, 2016 at 3:03pm