Retrieve content from a resource

@param $url

@return \Guzzle\Http\EntityBodyInterface|string
434941
protected function get($url)
    {
        $request = $this->http->get(
            $url,
            array('User-Agent' => self::USER_AGENT.' v.'.self::VERSION)
        );

        $response = $request->send();

        if (!$response->isSuccessful()) {
            $this->log('fail with '.$response->getStatusCode().' http code in url "'.$url.'" ');

            return;
        }
        $this->logger->log(LogLevel::INFO, 'retrieved url "'.$url.'" ');

        return $response->getBody();
    }
480313
public static function get( $url )
	{
		$checksum	= "6".self::calculateChecksum( self::strord( "info:".$url ) );
		$googleUrl	= "www.google.com/search?client=navclient-auto&ch=".$checksum."&features=Rank&q=info:".$url;
		$curl		= new Net_CURL( $googleUrl );
		$response	= $curl->exec();
		$position	= strpos( $response, "Rank_" );
		if( $position === FALSE )
			throw new Exception( 'Response does not contain Rank.' );
		$pagerank = substr( $response, $position + 9 );
		return (int) $pagerank;
	}
503353
public function get($url)
    {
        $ch = curl_init();

        // set URL and other appropriate options
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

        // grab URL and pass it to the browser
        $content = curl_exec($ch);
        $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
        // close cURL resource, and free up system resources
        if ($content === false) {
            throw new \Exception("CurlProxy error: " . curl_error($ch) . " when calling $url");
        }
        curl_close($ch);

        return $http_code == 200 && !empty($content) ? $content : false;
    }
952953
public function download($url)
	{
		$getResult = $this->session->get($url);

		if (!$getResult->success) {
			$this->error = array();
			$this->error['file'] = 'Download error (HTTP status: ' . $getResult->status_code . ')';
			$this->error['http'] = $getResult->status_code;
			return null;
		}
		return $getResult->body;
	}
595368
public function get($url, $params = array())
    {
        $request = $this->provider->request($url, $params);
        $response = $this->client->send($request);

        $data = $response->getBody()->getContents();
        $format = $this->getFormat($params, $response);

        return $this->serializer->deserialize($data, null, $format);
    }
540478
protected function getUrlContents(string $url): string
    {
        $request = $this->getRequest($url);

        return $this->getParsedResponse($request);
    }
84235
protected function getDetailByUrl(string $url)
    {
        try {
            $gc         =   new GC();
            $crawler    =   $gc->request('GET', $url);
            $cover  = $crawler->filter('table')->eq(0)->filter('img')->eq(0)->attr('src');
            $trs    = $crawler->filter('table')->eq(5)->filter('tr');
            $id     = $trs->eq(0)->filter('span')->eq(1)->text();
            $artist = $trs->eq(1)->filter('span')->eq(1)->text();
            $title  = '';
            for ($i = 1; $i < $trs->eq(8)->filter('span')->count(); $i++) {
                $title .= $trs->eq(8)->filter('span')->eq($i)->text();
            }
            $asset = new Nishikie($id, $url, $title, $cover, $artist);
        } catch (\GuzzleHttp\Exception\ConnectException $e) {
            $asset = null;
        }
        return $asset;
    }
861383
public static function fetchJsonResponse(string $url): string
    {
        $response = self::getBrowser()->get($url, [
            'Accept' => 'application/json',
            'X-Internal-Request' => 'true'
        ]);

        self::handleFailure($response);

        return $response->getBody()->getContents();
    }
318778
public function url_get_contents($url) {

        $content = '';

		if (\function_exists('curl_exec')){
            $conn = \curl_init($url);
            \curl_setopt($conn, CURLOPT_SSL_VERIFYPEER, true);
            \curl_setopt($conn, CURLOPT_FRESH_CONNECT,  true);
            \curl_setopt($conn, CURLOPT_RETURNTRANSFER, 1);
            \curl_setopt($conn,CURLOPT_USERAGENT,'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.52 Safari/537.17');
            \curl_setopt($conn, CURLOPT_AUTOREFERER, true);
            \curl_setopt($conn, CURLOPT_FOLLOWLOCATION, 1);
            \curl_setopt($conn, CURLOPT_VERBOSE, 0);
            $content = (\curl_exec($conn));
            \curl_close($conn);
        }
        if (!$content && \function_exists('file_get_contents')){
            $content = @\file_get_contents($url);
        }
        if (!$content && \function_exists('fopen') && function_exists('stream_get_contents')){
            $handle  = @\fopen ($url, "r");
            $content = @\stream_get_contents($handle);
        }
        return $content;
	}
679582
private function resolveApiUrl($url)
    {
        $client = new Client([
            'defaults' => [
                'timeout' => 5,
            ],
        ]);
        $response = $client->get($url);
        $responseStatusCode = $response->getStatusCode();

        if (404 == $responseStatusCode) {
            throw new EntityNotFoundException();
        }

        if (500 == $responseStatusCode) {
            throw new HttpException('Http exception');
        }

        return $response->json(['object' => false]);
    }
141998
public function fileGetContents($url)
    {
        $rawResponse = file_get_contents($url, false, $this->stream);
        $this->responseHeaders = $http_response_header ?: [];

        return $rawResponse;
    }
658743
function ParseUrl($url) {
	    $content = null;

    	$this->Clear();

		$this->url = htmlspecialchars_decode($url);

	    ob_start();
	    if (function_exists('curl_init')) {
		    //curl is the preferred function
		    $crl = curl_init();
		    curl_setopt($crl, CURLOPT_URL, $url);
		    curl_setopt($crl, CURLOPT_RETURNTRANSFER, 1);
		    curl_setopt($crl, CURLOPT_CONNECTTIMEOUT, 5);
		    curl_setopt($crl, CURLOPT_TIMEOUT, 20);
		    $FileData = curl_exec($crl);
		    $FileInfo = curl_getinfo($crl);
		    curl_close($crl);
		    if ($FileInfo['http_code'] != 200) {
			    throw new \HttpRequestException($FileInfo['http_code'] . ' error for file: ' . $url);
		    }
	    } else {
		    //see if we can use fopen to get file
		    $fopen_check = ini_get('allow_url_fopen');
		    if (!empty($fopen_check)) {
			    $content = file_get_contents($url);
		    } else {
			    throw new \RuntimeException('CURL_DISABLED');
		    }
	    }
	    ob_end_clean();

		if(strlen($content)) {
			$this->modifyContent($content);
			$this->ParseStr($content);
			return true;
		} else {
			return false;
		}
	}
279054
protected function loadResource(string $entityClass, string $url)
    {
        $resource = $this->restClient->getResource($entityClass, $url);

        return $resource->getEntity();
    }
354059
protected function getValidContentUrl($url)
    {
        if (null === $this->redirectApi && false !== $redirectApi = $this->cache->read('redirect-api')) {
            $this->redirectApi = $redirectApi;
        }

        if (\is_string($this->redirectApi) && 0 === strpos($url, $this->getRepositoryApiUrl())) {
            $url = $this->redirectApi.substr($url, \strlen($this->getRepositoryApiUrl()));
        }

        return $url;
    }
852524
public function retrieveData($url)
    {
        if (!is_null($this->getAuthorizationToken())) {
            $this->curlWrapper->setHeader('Authorization', $this->getAuthorizationToken());
        }

        $this->retrieve($url);

        return $this->curlWrapper->response;
    }
1149048
public function getContent($url)
    {
        $cache = $this->getCache($url);
        if ($cache->isCached('content')) {
            $content = $cache->retrieve('content');
        } else {
            $content = $this->downloader->getContent($url);
            foreach ($this->getStrippedHtmlTags() as $strippedHtmlTag) {
                $content = preg_replace("/<{$strippedHtmlTag}.*?>.*?<\/{$strippedHtmlTag}>/is", "", $content);
            }
            $cache->store('content', $content);
        }
        return $content;
    }
998133
protected function fetchURL($URL)
    {
        $cookieHeader = [];
        if ($this->cookie) {
            $cookieHeader[] = 'Cookie: ' . $this->cookie . ';';
        }

        $curl = curl_init();
        curl_setopt($curl, CURLOPT_URL, $URL);
        curl_setopt($curl, CURLOPT_HEADER, 1);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($curl, CURLOPT_HTTPHEADER, $cookieHeader);

        $body = null;
        $result = curl_exec($curl);
        if ($result) {
            $parts = explode("\r\n\r\n", $result, 2);
            $headers = explode("\r\n", $parts[0]);
            if (!$this->cookie) {
                $setCookieString = 'Set-Cookie: ';
                foreach ($headers as $header) {
                    if (strpos($header, $setCookieString) === 0) {
                        $cookieString = substr($header, strlen($setCookieString));
                        $cookieStringParts = explode(';', $cookieString);
                        $this->cookie = $cookieStringParts[0];
                        break;
                    }
                }
            }

            $body = $parts[1];
        }

        return $body;
    }