$error['error_description'] = $description; } $res->body(json_encode($error)); }; $source = parse_url($sourceURL); # Verify $source is valid if ($source == FALSE || !array_key_exists('scheme', $source) || !in_array($source['scheme'], array('http', 'https')) || !array_key_exists('host', $source) || $source['host'] == gethostbyname($source['host'])) { $error($res, 'source_not_found'); return; } $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $sourceURL); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $html = curl_exec($ch); $parser = new ParserPlus($html); $output = $parser->parse(); $page = new MF2Page($output); $data = array('name' => null, 'content' => null, 'published' => null, 'published_ts' => null, 'author' => array('name' => null, 'url' => null, 'photo' => null)); if ($page->hentry) { $data['mf2'] = $output; if ($page->hentry->property('name')) { $data['name'] = trim($page->hentry->property('name', true)); } if ($page->hentry->author) { if ($page->hentry->author->url) { $data['author']['url'] = $page->hentry->author->url; } if ($page->hentry->author->name) { $data['author']['name'] = $page->hentry->author->name; } if ($page->hentry->author->photo) {