小编Jac*_*ack的帖子

从Page Post Likes'summary'获取'total_count' - Facebook PHP SDK(已关闭)

我是PHP和Facebook PHP SDK的新手,我希望'like_count''likes' 'summary'Facebook页面帖子中获取.我当前的代码包含以下内容:

$response = $fb->get('/me/posts?fields=admin_creator,likes.limit(0).summary(true)&limit=30');
$getLikeCount = $response->getGraphEdge()->asArray();
foreach($getLikeCount as $likekey){
    if(isset($likekey['likes'])){
        var_export($likekey['likes']);
        foreach ($likekey['likes'] as $likekey){
            //echo $likekey['total_count'] . '<br>';
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

var_export($likekey['likes']);出口空白阵列,同时var_export($likekey['summary']);返回null.但是,在Graph API Explorer中,它返回以下内容:

{
      "admin_creator": {
        "name": "NAME",
        "id": "ID"
      },
      "id": "ID",
      "likes": {
        "data": [
        ],
        "summary": {
          "total_count": 1022,
          "can_like": true,
          "has_liked": false
        }
      }
    },
Run Code Online (Sandbox Code Playgroud)

我如何访问该'total_count'字段,因为通过我的方法访问它'likes'并且" summary'不工作".

编辑:使用getGraphEdge()->asArray();将无法工作,因为它不返回摘要数组.我会以某种方式获取值getDecodedBody();或其他方法.如果我使用$getLikeCount = $response->getDecodedBody();,使用此代码: …

php facebook facebook-graph-api facebook-php-sdk

1
推荐指数
1
解决办法
4463
查看次数