2011-08-08 20 views
0

Facebook PHP SDKからFacebook Graphs Serverへの正確なリクエストをログファイルに出力することはできますか?グラフ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

はあなたではなく、実際のhttpリクエストが行わmakeRequest機能を見ている必要があります。私は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)に入れ、 'new Facebook'の代わりに' new FacebookLogger'を書き込みます。 –

+0

ありがとうございました。本当に役に立ちました! – Immo