Php 无法将响应从图形转换为图形边缘,因为响应看起来不像图形边缘

Php 无法将响应从图形转换为图形边缘,因为响应看起来不像图形边缘,php,facebook,Php,Facebook,我正在使用以下代码段: // posting on user timeline using publish_actins permission try { // message must come from the user-end $data = ['message' => 'something...']; $request = $fb->post('/me/feed', $data); $response = $re

我正在使用以下代码段:

// posting on user timeline using publish_actins permission
try {
        // message must come from the user-end
        $data = ['message' => 'something...'];
        $request = $fb->post('/me/feed', $data);
        $response = $request->getGraphEdge()->asArray;
    } catch(Facebook\Exceptions\FacebookResponseException $e) {
        // When Graph returns an error
        echo 'Graph returned an error: ' . $e->getMessage();
        exit;
    } catch(Facebook\Exceptions\FacebookSDKException $e) {
        // When validation fails or other local issues
        echo 'Facebook SDK returned an error: ' . $e->getMessage();
        exit;
    }
我收到此警报,但我成功地在我的墙上发布:

“Facebook SDK返回错误:无法从图形转换响应 因为响应看起来不像GraphEdge,所以将其添加到GraphEdge。 请尝试改用GraphNodeFactory::makeGraphNode()


有人能帮我吗?

您必须更改此代码的$response

$response = $request->getGraphNode();
$id = $response['id'];

首先,检查您是否已请求相关权限()
然后尝试检查$request,看看里面有什么。 通常发生在两种情况下:
1当您的请求没有响应时(例如,在本例中,您的提要上没有任何内容)
2当响应本身是一个图形边缘时

祝你好运试试这个


$request->getGraphEdge()

Facebook->post
方法返回一个对象。