src/Client.php
protected function _sendRequest( array $parameters )
   {

      $this->_curlInfo = [];

         // Merge defined parameters with default parameters
      $parameters = array_merge( static::DEFAULT_REQUEST_PARAMS, $parameters );

      // close existing curl handle if defined
      $this->_closeCurl();

      // Init the curl handle
      $this->_initCurl( $parameters );

      // If output should be redirected to a file, set the option
      $toFilePointer = null;
      if ( isset( $parameters[ 'toFile' ] ) )
      {

         $toFilePointer = @\fopen( $parameters[ 'toFile' ], 'wb' );

         if ( ! $toFilePointer )
         {
            ( $this->_onError )( 'HTTPClient can not open file "' . $parameters[ 'toFile' ] . '" for writing!' );
            return false;
         }

         \curl_setopt( $this->_curlHandle, CURLOPT_FILE, $toFilePointer );

      }

      // Do the HTTP request while success or error
      do { $response = \curl_exec( $this->_curlHandle ); }
      while ( false === $response &&
              0 !== --$parameters['attemptsMax'] &&
              false !== \sleep( $parameters[ 'attemptsDelay' ] ) );

      // Close to file pointer if defined
      if ( null !== $toFilePointer )
      {
         \fclose( $toFilePointer );
         // delete the to file if no valid response exists
         if ( false === $response )
         {
            \unlink( $parameters[ 'toFile' ] );
         }
      }

      $error = @\curl_error( $this->_curlHandle );

      $this->_curlInfo = @\curl_getinfo( $this->_curlHandle );

      if ( ! empty( $error ) )
      {

         ( $this->_onError )( $error );
         return false;
      }

      if ( false === $response )
      {

         ( $this->_onError )( 'HTTPClient can not get a response from "' . $parameters[ 'url' ] . '"!' );
         return false;
      }

      // Saving response content into lastpageFile
      if ( null !== $this->_lastResponseToFile )
      {
         \file_put_contents( $this->_lastResponseToFile, $response );
      }

      return $response;

   }
protected function _sendRequest( array $parameters )
   {

      $this->_curlInfo = [];

         // Merge defined parameters with default parameters
      $parameters = array_merge( static::DEFAULT_REQUEST_PARAMS, $parameters );

      // close existing curl handle if defined
      $this->_closeCurl();

      // Init the curl handle
      $this->_initCurl( $parameters );

      // If output should be redirected to a file, set the option
      $toFilePointer = null;
      if ( isset( $parameters[ 'toFile' ] ) )
      {

         $toFilePointer = @\fopen( $parameters[ 'toFile' ], 'wb' );

         if ( ! $toFilePointer )
         {
            ( $this->_onError )( 'HTTPClient can not open file "' . $parameters[ 'toFile' ] . '" for writing!' );
            return false;
         }

         \curl_setopt( $this->_curlHandle, CURLOPT_FILE, $toFilePointer );

      }

      // Do the HTTP request while success or error
      do { $response = \curl_exec( $this->_curlHandle ); }
      while ( false === $response &&
              0 !== --$parameters['attemptsMax'] &&
              false !== \sleep( $parameters[ 'attemptsDelay' ] ) );

      // Close to file pointer if defined
      if ( null !== $toFilePointer )
      {
         \fclose( $toFilePointer );
         // delete the to file if no valid response exists
         if ( false === $response )
         {
            \unlink( $parameters[ 'toFile' ] );
         }
      }

      $error = @\curl_error( $this->_curlHandle );

      $this->_curlInfo = @\curl_getinfo( $this->_curlHandle );

      if ( ! empty( $error ) )
      {

         ( $this->_onError )( $error );
         return false;
      }

      if ( false === $response )
      {

         ( $this->_onError )( 'HTTPClient can not get a response from "' . $parameters[ 'url' ] . '"!' );
         return false;
      }

      // Saving response content into lastpageFile
      if ( null !== $this->_lastResponseToFile )
      {
         \file_put_contents( $this->_lastResponseToFile, $response );
      }

      return $response;

   }
protected function _sendRequest ( array $ parameters ) { $ this -> _curlInfo = [ ] ; // Merge defined parameters with default parameters $ parameters = array_merge ( static :: DEFAULT_REQUEST_PARAMS , $ parameters ) ; // close existing curl handle if defined $ this -> _closeCurl ( ) ; // Init the curl handle $ this -> _initCurl ( $ parameters ) ; // If output should be redirected to a file, set the option $ toFilePointer = null ; if ( isset ( $ parameters [ 'toFile' ] ) ) { $ toFilePointer = @ \ fopen ( $ parameters [ 'toFile' ] , 'wb' ) ; if ( ! $ toFilePointer ) { ( $ this -> _onError ) ( 'HTTPClient can not open file "' . $ parameters [ 'toFile' ] . '" for writing!' ) ; return false ; } \ curl_setopt ( $ this -> _curlHandle , CURLOPT_FILE , $ toFilePointer ) ; } // Do the HTTP request while success or error do { $ response = \ curl_exec ( $ this -> _curlHandle ) ; } while ( false === $ response && 0 !== -- $ parameters [ 'attemptsMax' ] && false !== \ sleep ( $ parameters [ 'attemptsDelay' ] ) ) ; // Close to file pointer if defined if ( null !== $ toFilePointer ) { \ fclose ( $ toFilePointer ) ; // delete the to file if no valid response exists if ( false === $ response ) { \ unlink ( $ parameters [ 'toFile' ] ) ; } } $ error = @ \ curl_error ( $ this -> _curlHandle ) ; $ this -> _curlInfo = @ \ curl_getinfo ( $ this -> _curlHandle ) ; if ( ! empty ( $ error ) ) { ( $ this -> _onError ) ( $ error ) ; return false ; } if ( false === $ response ) { ( $ this -> _onError ) ( 'HTTPClient can not get a response from "' . $ parameters [ 'url' ] . '"!' ) ; return false ; } // Saving response content into lastpageFile if ( null !== $ this -> _lastResponseToFile ) { \ file_put_contents ( $ this -> _lastResponseToFile , $ response ) ; } return $ response ; }
Runs the request and return the response.

@param  array $parameters The request parameters.
@return string|false Returns the response in the usual case, TRUE if result is a file and FALSE on error.
Runs the request and return the response .