获取总评论、点赞、分享 (PHP Facebook API v2.4)

Get Total Comment, Like, Share (PHP Facebook API v2.4)

我已阅读有关 comment and like 的 Facebook 文档,但仍然对如何从我的 Facebook 页面提要中获得完整评论、点赞和分享感到困惑。

示例我如何从我的页面提要中获取评论:

$facebook = new Facebook\Facebook([
    'app_id' => '',
    'app_secret' => '',
    'default_access_token' => '',
    'default_graph_version' => 'v2.4'
]);

$response = $facebook->get(id/comments?summary=true&fields=from,parent,id,message,created_time&filter=stream')->getGraphEdge();

print_r($response);

响应结果:

[metaData:protected] => Array
    (
        [summary] => Array
            (
                [order] => chronological
                [total_count] => 16
                [can_comment] => 
            )

    )
[items:protected] => Array
    (
        [0]
        ...
        [15]
    )

我知道如何获取字段数据,我使用 $response->asArray(); 但如何获取 summary -> total_count

有辅助函数$response->getTotalCount()

对于任何其他值,您可以使用 $response->getMetadata()['summary']['order']