Browse Source

send http accept header requesting HTML

main
Aaron Parecki 7 years ago
parent
commit
42480ed79b
No known key found for this signature in database GPG Key ID: 276C2817346D6056
3 changed files with 5 additions and 3 deletions
  1. +1
    -1
      controllers/API.php
  2. +1
    -1
      controllers/Controller.php
  3. +3
    -1
      lib/Telegraph/HTTP.php

+ 1
- 1
controllers/API.php View File

@ -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

+ 1
- 1
controllers/Controller.php View File

@ -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));

+ 3
- 1
lib/Telegraph/HTTP.php View File

@ -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);

Loading…
Cancel
Save