Immo
Immo

Reputation: 601

Facebook PHP SDK for Graph API

Is it possible to print to my log files the exact request from Facebook PHP SDK to the Facebook Graphs Server?

Can someone explain me how to modify the Facebook PHP Library https://github.com/facebook/php-sdk

I found:

/**
* Invoke the Graph API.
*
* @param String $path the path (required)
* @param String $method the http method (default 'GET')
* @param Array $params the query/post data
* @return the decoded response object
* @throws FacebookApiException
*/
protected function _graph($path, $method = 'GET', $params = array()) {
if (is_array($method) && empty($params)) {
  $params = $method;
  $method = 'GET';
}
$params['method'] = $method; // method override as we always do a POST

$result = json_decode($this->_oauthRequest(
  $this->getUrl('graph', $path),
  $params
), true);

// results are returned, errors are thrown
if (is_array($result) && isset($result['error'])) {
  $this->throwAPIException($result);
}

return $result;
}

Upvotes: 0

Views: 587

Answers (1)

Sascha Galley
Sascha Galley

Reputation: 16101

You should rather have a look at the makeRequest function where the actual http request takes place. Since I wouldn't play around in the api, you could also extend the class and override the method:

class FacebookLogger extends Facebook {

    protected function makeRequest($url, $params, $ch=null) {

        var_dump($url);
        var_dump($params);

        parent::makeRequest($url, $params, $ch);

    }

}

Upvotes: 1

Related Questions