Jonah::readURL PHP Method

readURL() public static method

Obtain the list of stories from the passed in URI.
Deprecation: Will be removed when external channels are removed.
public static readURL ( string $url )
$url string The url to get the list of the channel's stories.
    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;
    }