webmention-implementation-guide
Sending WebmentionsThe beauty of simple protocols is that you can do most of this manually very easily.
curl -i -s $target | grep 'rel="webmention"'
curl -i -d "source=$your_url&target=$target_url" $targets_webmention_endpoint One-liner webmentionsThis will send the webmention in a single command: curl -i -d "source=$your_url&target=$target_url" `curl -i -s $target_url | grep 'rel="http://webmention.org/"' | sed 's/rel="webmention"//' | grep -o -E 'https?://[^ ">]+' | sort | uniq` See also this gist for sending pingbacks manually: https://gist.github.com/aaronpk/5744879 Endpoint Discovery in PHPThe following code is a set of simple short & flat functions for doing discovery of webmentions in PHP. Automatic discovery could be implemented in PHP by:
$w = 0;
$c = curl_init($url);
curl_setopt($c, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
$s = curl_exec($c);
$dom = new DOMDocument();
$dom->loadHTML($s);
$domx = new DOMXPath($dom);
$ws = $domx->query(xphasrel('webmention')); // except with link instead of *
if ($ws) {
$w = $ws->item(0)->getAttribute('href');
}
// if ($w!=0) then it has a webmention endpoint.
// this code could be changed into a html_webmention_rel($url) function,
// to be called only if head_http_rels($url) returns no "rels" array
// or has no "webmention" item(s) in said array
Accepting WebmentionsCurrently the easiest way to test consuming webmentions is to implement sending them, then send yourself mentions. Once you’re ready to test integration with another site, you can either ask someone in IRC to send you a comment, or mention your page in IRC and send a webmention from IRC log URL for that line to your URL. For example this IRC line links to http://caseorganic.com/notes/2014/02/18/1/. Pasting the URL for the IRC line into the indiewebify.me webmention sender will send webmentions for all the links on the page. Then you can check your page or your server logs to see if the webmention was successful — in this case the comment successfully showed up on the target page.
Resources
|



















