2011-08-08 66 views
0

是否可以向我的日志文件打印Facebook PHP SDK到Facebook图形服务器的确切请求?用于图形API的Facebook PHP SDK

有人能解释我如何修改Facebook的PHP库https://github.com/facebook/php-sdk

我发现:

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

回答

1

你还是看看在makeRequest功能在实际的HTTP请求发生。由于我不会在api中玩耍,您还可以扩展课程并覆盖该方法:

class FacebookLogger extends Facebook { 

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

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

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

    } 

} 
+0

非常感谢。我应该把这个放在哪里?里面facebook.php或base_facebook.php或可能在我的代码? – Immo

+0

创建一个新文件(例如fb_logger.php),包含它(和官方的fb api),而不是'新的Facebook'写'新的FacebookLogger'。 –

+0

非常感谢。真的有帮助! – Immo