调用未定义的方法Facebook \ FacebookRequest :: getGraphNode()

时间:2017-05-05 08:19:42

标签: php facebook

我收到以下错误:

  

调用未定义的方法Facebook \ FacebookRequest :: getGraphNode()

从这段代码:

    $params = array();

    try {
        // Returns a `Facebook\FacebookResponse` object
        $response = $facebook->request('GET', '/123456789/feed', $params,'fgj123fgj123fgj');
    } catch(Facebook\Exceptions\FacebookResponseException $e) {
        echo 'Graph returned an error: ' . $e->getMessage();
        exit;
    } catch(Facebook\Exceptions\FacebookSDKException $e) {
        echo 'Facebook SDK returned an error: ' . $e->getMessage();
        exit;
    }
    $graphNode = $response->getGraphNode();


    print_r($graphNode);

该行:

$graphNode = $response->getGraphNode();

直接来自他们的文档:https://developers.facebook.com/docs/php/GraphNode/5.0.0

任何解决方案,以便我可以正确返回数据?

1 个答案:

答案 0 :(得分:0)

您必须像 ->request() 一样替换 ->get() (根据您的示例):

$response = $facebook->get('GET', '/123456789/feed', $params,'fgj123fgj123fgj');

喜欢写在documentation

$fb = new Facebook\Facebook(\* *\);
// Returns a `Facebook\FacebookResponse` object
$response = $fb->get('/something');