protected function _fetchRemoteFile($url)
  {
    // try to fetch the file
    if ($this->_use_curl) {
      $connection = $this->_getCurlInitialization($url);
      $this->_curl_setopt($connection, CURLOPT_RETURNTRANSFER, 1);
      $this->_curl_setopt($connection, CURLOPT_HEADER, 0);
      // no SSL validation for downloading media
      $this->_curl_setopt($connection, CURLOPT_SSL_VERIFYPEER, 1);
      $this->_curl_setopt($connection, CURLOPT_SSL_VERIFYHOST, 2);
      $this->_curl_setopt($connection, CURLOPT_TIMEOUT_MS, $this->_timeouts['remote']);
      $this->_curl_setopt($connection, CURLOPT_CONNECTTIMEOUT_MS, $this->_timeouts['remote'] / 2);
      // find files that have been redirected
      $this->_curl_setopt($connection, CURLOPT_FOLLOWLOCATION, true);
      // process compressed images
      $this->_curl_setopt($connection, CURLOPT_ENCODING, 'gzip,deflate,sdch');
      $result = $this->_curl_exec($connection);
      if ($result !== false
        && $this->_curl_getinfo($connection, CURLINFO_HTTP_CODE) === 200
      ) {
        return $result;
      }
      throw new CodebirdMediaException('Downloading a remote media file failed.');
      return false;
    }
    // no cURL
    $contextOptions = [
      'http' => [
        'method'           => 'GET',
        'protocol_version' => '1.1',
        'timeout'          => $this->_timeouts['remote']
      ],
      'ssl' => [
        'verify_peer'  => false
      ]
    ];
    list($result, $headers) = $this->_getNoCurlInitialization($url, $contextOptions);
    if ($result !== false
      && preg_match('/^HTTP\/\d\.\d 200 OK$/', $headers[0])
    ) {
      return $result;
    }
    throw new CodebirdMediaException('Downloading a remote media file failed.');
    return false;
  }
protected function _fetchRemoteFile($url)
  {
    // try to fetch the file
    if ($this->_use_curl) {
      $connection = $this->_getCurlInitialization($url);
      $this->_curl_setopt($connection, CURLOPT_RETURNTRANSFER, 1);
      $this->_curl_setopt($connection, CURLOPT_HEADER, 0);
      // no SSL validation for downloading media
      $this->_curl_setopt($connection, CURLOPT_SSL_VERIFYPEER, 1);
      $this->_curl_setopt($connection, CURLOPT_SSL_VERIFYHOST, 2);
      $this->_curl_setopt($connection, CURLOPT_TIMEOUT_MS, $this->_timeouts['remote']);
      $this->_curl_setopt($connection, CURLOPT_CONNECTTIMEOUT_MS, $this->_timeouts['remote'] / 2);
      // find files that have been redirected
      $this->_curl_setopt($connection, CURLOPT_FOLLOWLOCATION, true);
      // process compressed images
      $this->_curl_setopt($connection, CURLOPT_ENCODING, 'gzip,deflate,sdch');
      $result = $this->_curl_exec($connection);
      if ($result !== false
        && $this->_curl_getinfo($connection, CURLINFO_HTTP_CODE) === 200
      ) {
        return $result;
      }
      throw new CodebirdMediaException('Downloading a remote media file failed.');
      return false;
    }
    // no cURL
    $contextOptions = [
      'http' => [
        'method'           => 'GET',
        'protocol_version' => '1.1',
        'timeout'          => $this->_timeouts['remote']
      ],
      'ssl' => [
        'verify_peer'  => false
      ]
    ];
    list($result, $headers) = $this->_getNoCurlInitialization($url, $contextOptions);
    if ($result !== false
      && preg_match('/^HTTP\/\d\.\d 200 OK$/', $headers[0])
    ) {
      return $result;
    }
    throw new CodebirdMediaException('Downloading a remote media file failed.');
    return false;
  }
protected function _fetchRemoteFile ( $ url ) { // try to fetch the file if ( $ this -> _use_curl ) { $ connection = $ this -> _getCurlInitialization ( $ url ) ; $ this -> _curl_setopt ( $ connection , CURLOPT_RETURNTRANSFER , 1 ) ; $ this -> _curl_setopt ( $ connection , CURLOPT_HEADER , 0 ) ; // no SSL validation for downloading media $ this -> _curl_setopt ( $ connection , CURLOPT_SSL_VERIFYPEER , 1 ) ; $ this -> _curl_setopt ( $ connection , CURLOPT_SSL_VERIFYHOST , 2 ) ; $ this -> _curl_setopt ( $ connection , CURLOPT_TIMEOUT_MS , $ this -> _timeouts [ 'remote' ] ) ; $ this -> _curl_setopt ( $ connection , CURLOPT_CONNECTTIMEOUT_MS , $ this -> _timeouts [ 'remote' ] / 2 ) ; // find files that have been redirected $ this -> _curl_setopt ( $ connection , CURLOPT_FOLLOWLOCATION , true ) ; // process compressed images $ this -> _curl_setopt ( $ connection , CURLOPT_ENCODING , 'gzip,deflate,sdch' ) ; $ result = $ this -> _curl_exec ( $ connection ) ; if ( $ result !== false && $ this -> _curl_getinfo ( $ connection , CURLINFO_HTTP_CODE ) === 200 ) { return $ result ; } throw new CodebirdMediaException ( 'Downloading a remote media file failed.' ) ; return false ; } // no cURL $ contextOptions = [ 'http' => [ 'method' => 'GET' , 'protocol_version' => '1.1' , 'timeout' => $ this -> _timeouts [ 'remote' ] ] , 'ssl' => [ 'verify_peer' => false ] ] ; list ( $ result , $ headers ) = $ this -> _getNoCurlInitialization ( $ url , $ contextOptions ) ; if ( $ result !== false && preg_match ( '/^HTTP\/\d\.\d 200 OK$/' , $ headers [ 0 ] ) ) { return $ result ; } throw new CodebirdMediaException ( 'Downloading a remote media file failed.' ) ; return false ; }
Fetches a remote file

@param string $url The URL to download from

@return mixed The file contents or FALSE
@throws \Exception
Fetches a remote file