diff --git a/controllers/API.php b/controllers/API.php index 337283b..69b9bc6 100644 --- a/controllers/API.php +++ b/controllers/API.php @@ -121,7 +121,7 @@ class API { $found[$target] = null; } else { - $sourceData = $this->http->get($source); + $sourceData = $this->http->get($source, ['Accept: text/html, */*']); $doc = new DOMDocument(); libxml_use_internal_errors(true); # suppress parse errors and warnings diff --git a/controllers/Controller.php b/controllers/Controller.php index 10475f3..47df9fa 100644 --- a/controllers/Controller.php +++ b/controllers/Controller.php @@ -277,7 +277,7 @@ class Controller { $sourceURL = $request->get('url'); $client = new IndieWeb\MentionClient(); - $source = $this->http->get($sourceURL); + $source = $this->http->get($sourceURL, ['Accept: text/html, */*']); $parsed = \Mf2\parse($source['body'], $sourceURL); $links = array_values($client->findOutgoingLinks($parsed)); diff --git a/lib/Telegraph/HTTP.php b/lib/Telegraph/HTTP.php index 8044575..8e06270 100644 --- a/lib/Telegraph/HTTP.php +++ b/lib/Telegraph/HTTP.php @@ -3,9 +3,11 @@ namespace Telegraph; class HTTP { - public function get($url) { + public function get($url, $headers=array()) { $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + if(count($headers)) + curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_HEADER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); $response = curl_exec($ch);