protected function makeRequest($path, $method = 'GET', $params = array(), $ch = NULL) {
    if (!$ch)
      $ch = curl_init();

    $opts = self::$CURL_OPTS;
    if ($params) {
      switch ($method) {
        case 'GET':
          $path .= '?' . http_build_query($params, NULL, '&');
          break;
        // Method override as we always do a POST.
        default:
          if ($this->getVariable('file_upload_support')) {
            $opts[CURLOPT_POSTFIELDS] = $params;
          }
          else {
            $opts[CURLOPT_POSTFIELDS] = http_build_query($params, NULL, '&');
          }
      }
    }
    
    $opts[CURLOPT_URL] = $path;

    // Disable the 'Expect: 100-continue' behaviour. This causes CURL to wait
    // for 2 seconds if the server does not support this header.
    if (isset($opts[CURLOPT_HTTPHEADER])) {
      $existing_headers = $opts[CURLOPT_HTTPHEADER];
      $existing_headers[] = 'Expect:';
      $opts[CURLOPT_HTTPHEADER] = $existing_headers;
    }
    else {
      $opts[CURLOPT_HTTPHEADER] = array('Expect:');
    }

    curl_setopt_array($ch, $opts);
    
    //Paul: Ignore certs for the moment
    curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0); 
    
    //curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, TRUE);
    //curl_setopt($ch, CURLOPT_CAINFO, "/path/to/cacert.pem");
    $result = curl_exec($ch);

    if (curl_errno($ch) == 60) { // CURLE_SSL_CACERT
      error_log('Invalid or no certificate authority found, using bundled information');
      curl_setopt($ch, CURLOPT_CAINFO,
                  dirname(__FILE__) . '/fb_ca_chain_bundle.crt');
      $result = curl_exec($ch);
    }

    if ($result === FALSE) {
      $e = new OAuth2Exception(array(
        'code' => curl_errno($ch),
        'message' => curl_error($ch),
      ));
      curl_close($ch);
      throw $e;
    }
    curl_close($ch);

    // Split the HTTP response into header and body.
    list($headers, $body) = explode("\r\n\r\n", $result);
    $headers = explode("\r\n", $headers);

    // We catch HTTP/1.1 4xx or HTTP/1.1 5xx error response.
    if (strpos($headers[0], 'HTTP/1.1 4') !== FALSE || strpos($headers[0], 'HTTP/1.1 5') !== FALSE) {
      $result = array(
        'code' => 0,
        'message' => '',
      );

      if (preg_match('/^HTTP\/1.1 ([0-9]{3,3}) (.*)$/', $headers[0], $matches)) {
        $result['code'] = $matches[1];
        $result['message'] = $matches[2];
      }

      // In case retrun with WWW-Authenticate replace the description.
      foreach ($headers as $header) {
        if (preg_match("/^WWW-Authenticate:.*error='(.*)'/", $header, $matches)) {
          $result['error'] = $matches[1];
        }
      }

      return json_encode($result);
    }

    return $body;
  }
protected function makeRequest($path, $method = 'GET', $params = array(), $ch = NULL) {
    if (!$ch)
      $ch = curl_init();

    $opts = self::$CURL_OPTS;
    if ($params) {
      switch ($method) {
        case 'GET':
          $path .= '?' . http_build_query($params, NULL, '&');
          break;
        // Method override as we always do a POST.
        default:
          if ($this->getVariable('file_upload_support')) {
            $opts[CURLOPT_POSTFIELDS] = $params;
          }
          else {
            $opts[CURLOPT_POSTFIELDS] = http_build_query($params, NULL, '&');
          }
      }
    }
    
    $opts[CURLOPT_URL] = $path;

    // Disable the 'Expect: 100-continue' behaviour. This causes CURL to wait
    // for 2 seconds if the server does not support this header.
    if (isset($opts[CURLOPT_HTTPHEADER])) {
      $existing_headers = $opts[CURLOPT_HTTPHEADER];
      $existing_headers[] = 'Expect:';
      $opts[CURLOPT_HTTPHEADER] = $existing_headers;
    }
    else {
      $opts[CURLOPT_HTTPHEADER] = array('Expect:');
    }

    curl_setopt_array($ch, $opts);
    
    //Paul: Ignore certs for the moment
    curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0); 
    
    //curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, TRUE);
    //curl_setopt($ch, CURLOPT_CAINFO, "/path/to/cacert.pem");
    $result = curl_exec($ch);

    if (curl_errno($ch) == 60) { // CURLE_SSL_CACERT
      error_log('Invalid or no certificate authority found, using bundled information');
      curl_setopt($ch, CURLOPT_CAINFO,
                  dirname(__FILE__) . '/fb_ca_chain_bundle.crt');
      $result = curl_exec($ch);
    }

    if ($result === FALSE) {
      $e = new OAuth2Exception(array(
        'code' => curl_errno($ch),
        'message' => curl_error($ch),
      ));
      curl_close($ch);
      throw $e;
    }
    curl_close($ch);

    // Split the HTTP response into header and body.
    list($headers, $body) = explode("\r\n\r\n", $result);
    $headers = explode("\r\n", $headers);

    // We catch HTTP/1.1 4xx or HTTP/1.1 5xx error response.
    if (strpos($headers[0], 'HTTP/1.1 4') !== FALSE || strpos($headers[0], 'HTTP/1.1 5') !== FALSE) {
      $result = array(
        'code' => 0,
        'message' => '',
      );

      if (preg_match('/^HTTP\/1.1 ([0-9]{3,3}) (.*)$/', $headers[0], $matches)) {
        $result['code'] = $matches[1];
        $result['message'] = $matches[2];
      }

      // In case retrun with WWW-Authenticate replace the description.
      foreach ($headers as $header) {
        if (preg_match("/^WWW-Authenticate:.*error='(.*)'/", $header, $matches)) {
          $result['error'] = $matches[1];
        }
      }

      return json_encode($result);
    }

    return $body;
  }
protected function makeRequest ( $ path , $ method = 'GET' , $ params = array ( ) , $ ch = NULL ) { if ( ! $ ch ) $ ch = curl_init ( ) ; $ opts = self :: $ CURL_OPTS ; if ( $ params ) { switch ( $ method ) { case 'GET' : $ path .= '?' . http_build_query ( $ params , NULL , '&' ) ; break ; // Method override as we always do a POST.
 default : if ( $ this -> getVariable ( 'file_upload_support' ) ) { $ opts [ CURLOPT_POSTFIELDS ] = $ params ; } else { $ opts [ CURLOPT_POSTFIELDS ] = http_build_query ( $ params , NULL , '&' ) ; } } } $ opts [ CURLOPT_URL ] = $ path ; // Disable the 'Expect: 100-continue' behaviour. This causes CURL to wait
 // for 2 seconds if the server does not support this header.
 if ( isset ( $ opts [ CURLOPT_HTTPHEADER ] ) ) { $ existing_headers = $ opts [ CURLOPT_HTTPHEADER ] ; $ existing_headers [ ] = 'Expect:' ; $ opts [ CURLOPT_HTTPHEADER ] = $ existing_headers ; } else { $ opts [ CURLOPT_HTTPHEADER ] = array ( 'Expect:' ) ; } curl_setopt_array ( $ ch , $ opts ) ; //Paul: Ignore certs for the moment
 curl_setopt ( $ ch , CURLOPT_SSL_VERIFYHOST , 0 ) ; curl_setopt ( $ ch , CURLOPT_SSL_VERIFYPEER , 0 ) ; //curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, TRUE);
 //curl_setopt($ch, CURLOPT_CAINFO, "/path/to/cacert.pem");
 $ result = curl_exec ( $ ch ) ; if ( curl_errno ( $ ch ) == 60 ) { // CURLE_SSL_CACERT
 error_log ( 'Invalid or no certificate authority found, using bundled information' ) ; curl_setopt ( $ ch , CURLOPT_CAINFO , dirname ( __FILE__ ) . '/fb_ca_chain_bundle.crt' ) ; $ result = curl_exec ( $ ch ) ; } if ( $ result === FALSE ) { $ e = new OAuth2Exception ( array ( 'code' => curl_errno ( $ ch ) , 'message' => curl_error ( $ ch ) , ) ) ; curl_close ( $ ch ) ; throw $ e ; } curl_close ( $ ch ) ; // Split the HTTP response into header and body.
 list ( $ headers , $ body ) = explode ( "\r\n\r\n" , $ result ) ; $ headers = explode ( "\r\n" , $ headers ) ; // We catch HTTP/1.1 4xx or HTTP/1.1 5xx error response.
 if ( strpos ( $ headers [ 0 ] , 'HTTP/1.1 4' ) !== FALSE || strpos ( $ headers [ 0 ] , 'HTTP/1.1 5' ) !== FALSE ) { $ result = array ( 'code' => 0 , 'message' => '' , ) ; if ( preg_match ( '/^HTTP\/1.1 ([0-9]{3,3}) (.*)$/' , $ headers [ 0 ] , $ matches ) ) { $ result [ 'code' ] = $ matches [ 1 ] ; $ result [ 'message' ] = $ matches [ 2 ] ; } // In case retrun with WWW-Authenticate replace the description.
 foreach ( $ headers as $ header ) { if ( preg_match ( "/^WWW-Authenticate:.*error='(.*)'/" , $ header , $ matches ) ) { $ result [ 'error' ] = $ matches [ 1 ] ; } } return json_encode ( $ result ) ; } return $ body ; }
Makes an HTTP request.

This method can be overriden by subclasses if developers want to do
fancier things or use something other than cURL to make the request.

@param $path
The target path, relative to base_path/service_uri or an absolute URI.
@param $method
(optional) The HTTP method (default 'GET').
@param $params
(optional The GET/POST parameters.
@param $ch
(optional) An initialized curl handle

@return
The JSON decoded response object.
Makes an HTTP request .