Open
Description
/**
* Fetches a URI and parses it for Open Graph data, returns
* false on error.
*
* @param $URI URI to page to parse for Open Graph data
* @return OpenGraph
*/
static public function fetch($URI) {
try {
$curl = curl_init($URI);
if ($curl === false) {
throw new Exception('failed to initialize');
}
curl_setopt($curl, CURLOPT_FAILONERROR, true);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 15);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($curl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
$response = curl_exec($curl);
if ($response === false) {
throw new Exception(curl_error($curl), curl_errno($curl));
}
curl_close($curl);
if (!empty($response)) {
return self::_parse($response);
} else {
return false;
}
} catch (Exception $e) {
trigger_error(sprintf(
'Curl failed with error #%d: %s',
$e->getCode(), $e->getMessage()),
E_USER_ERROR);
}
}
This got it working for me after checking cURL manually and then with problems with the SSL.
Metadata
Assignees
Labels
No labels