简体   繁体   English

用于图谱API的Facebook PHP SDK

[英]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? 是否可以将从Facebook PHP SDK到Facebook Graphs Server的确切请求打印到我的日志文件中?

Can someone explain me how to modify the Facebook PHP Library https://github.com/facebook/php-sdk 有人可以向我解释如何修改Facebook PHP库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. 您应该看一下实际HTTP请求发生的makeRequest函数。 Since I wouldn't play around in the api, you could also extend the class and override the method: 由于我不会在api中玩耍,因此您还可以扩展类并重写方法:

class FacebookLogger extends Facebook {

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

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

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

    }

}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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