public static function readURL($url)
{
global $conf;
$http = $GLOBALS['injector']->getInstance('Horde_Core_Factory_HttpClient')->create();
try {
$response = $http->get($url);
} catch (Horde_Http_Exception $e) {
throw new Jonah_Exception(sprintf(_("Could not open %s: %s"), $url, $e->getMessage()));
}
if ($response->code != '200') {
throw new Jonah_Exception(sprintf(_("Could not open %s: %s"), $url, $response->code));
}
$result = array('body' => $response->getBody());
$content_type = $response->getHeader('Content-Type');
if (preg_match('/.*;\\s?charset="?([^"]*)/', $content_type, $match)) {
$result['charset'] = $match[1];
} elseif (preg_match('/<\\?xml[^>]+encoding=["\']?([^"\'\\s?]+)[^?].*?>/i', $result['body'], $match)) {
$result['charset'] = $match[1];
}
return $result;
}