2011-08-08 63 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