From aca6432fc1d3042610e2a31e8717cbcf9e9d6cce Mon Sep 17 00:00:00 2001 From: Aaron Parecki Date: Wed, 24 May 2017 09:33:32 -0700 Subject: [PATCH] send `Accept: text/html` header closes #106 --- Mf2/Parser.php | 3 +++ bin/fetch-mf2 | 4 +--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Mf2/Parser.php b/Mf2/Parser.php index 11c6302..5341d9e 100644 --- a/Mf2/Parser.php +++ b/Mf2/Parser.php @@ -69,6 +69,9 @@ function fetch($url, $convertClassic = true, &$curlInfo=null) { curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_MAXREDIRS, 5); + curl_setopt($ch, CURLOPT_HTTPHEADER, array( + 'Accept: text/html' + )); $html = curl_exec($ch); $info = $curlInfo = curl_getinfo($ch); curl_close($ch); diff --git a/bin/fetch-mf2 b/bin/fetch-mf2 index 05a073e..2e8e578 100755 --- a/bin/fetch-mf2 +++ b/bin/fetch-mf2 @@ -31,9 +31,7 @@ if (!file_exists($url)) { } } -$html = file_get_contents($url); - -$result = Mf2\parse($html, $url); +$result = Mf2\fetch($url); if (defined('JSON_PRETTY_PRINT')) { echo json_encode($result, JSON_PRETTY_PRINT);