public function fetchURL($url, $followRedirects = true, $username = null, $password = null, $headers = array())
    {

        if (function_exists('curl_init')) {

            $contents = $this->curlRequest($url, false, $followRedirects, $username, $password, $headers);

            return $contents;

        } else {

            if ($this->userAgent != null) {
                $opts = array(
                    'http'=> array(
                    'user_agent'=> $this->userAgent,
                    'max_redirects' => $this->redirects,              // stop after 10 redirects
                  )
                );

            }

            if ($username && $password) {
                $opts = ($opts) ? $opts : array('http' => array());
                $opts['http']['header'] =
                    array('Authorization: Basic '
                        . base64_encode("$username:$password"));
            }

            if ($headers) {
                $opts['http']['header'] =$headers;
            }

            $context = ($opts) ? stream_context_create($opts) : null;

            unset($opts);

            $contents = @file_get_contents($url, false, $context);

            if ($contents === false)
                throw new HttpRequestException("Unknown error fetching URL '".$url."'");

            unset($context);
            unset($url);

            return $contents;
        }
    }