getHeaders(); if (isset($headers["link"])) { foreach($headers["link"] as $link) { if (preg_match('/rel=("?)webmention("?)/', $link)) { $matches = []; preg_match('/\<(..*?)\>/', $link, $matches); if (count($matches) > 1) { return $matches[1]; } } } } return null; } private static function absoluteURL(ResponseInterface $response, ?string $endpoint) : string | null { if (!$endpoint) { return null; } $url = $response->getInfo("redirect_url") ?? $response->getInfo('url'); $uri = Uri::createFromString($url); $endpoint = Uri::createFromString($endpoint); if (!UriInfo::isAbsolute($endpoint)) { return (string) UriResolver::resolve($endpoint, $uri); } return (string) $endpoint; } private static function parseBody(ResponseInterface $response) : string | null { $doc = new Crawler($response->getContent()); $webmentions = $doc->filter('[rel="webmention"][href]'); if ($webmentions->count()) { return $webmentions->first()->attr('href'); } return null; } }