Last active
March 16, 2024 22:15
-
-
Save adactio/6484118 to your computer and use it in GitHub Desktop.
Minimum viable webmention in PHP.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
# Licensed under a CC0 1.0 Universal (CC0 1.0) Public Domain Dedication | |
# http://creativecommons.org/publicdomain/zero/1.0/ | |
if (!isset($_POST['source']) || !isset($_POST['target'])) { | |
header($_SERVER['SERVER_PROTOCOL'] . ' 400 Bad Request'); | |
exit; | |
} | |
ob_start(); | |
$ch = curl_init($_POST['source']); | |
curl_setopt($ch,CURLOPT_USERAGENT,'mydomain (webmention.org)'); | |
curl_setopt($ch,CURLOPT_HEADER,0); | |
$ok = curl_exec($ch); | |
curl_close($ch); | |
$source = ob_get_contents(); | |
ob_end_clean(); | |
header($_SERVER['SERVER_PROTOCOL'] . ' 202 Accepted'); | |
if (stristr($source, $_POST['target'])) { | |
# Now do something with $source e.g. parse it for h-entry and h-card and store what you find. | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
license: http://creativecommons.org/publicdomain/zero/1.0/ por favor