简体   繁体   中英

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;
}

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);

    }

}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM