Facebook Graph Api url评论和分享计数不再有效

时间:2012-12-27 22:02:10

标签: facebook facebook-graph-api facebook-comments

我正在为我的博客使用facebook评论插件,直到现在,facebook图表api帮助我检索了我网站上每个帖子的评论数量。所以,正如我所说,我写的帖子就像一个月前一样,我可以使用php和json_decode检索注释计数,如下所示:

$wsurl  = 'http://www.example.com/title-of-the-post/';
$wsjson = json_decode(file_get_contents('https://graph.facebook.com/?ids='.$wsurl));
$cmcount = ($wsjson->$wsurl->comments) ? $wsjson->$wsurl->comments : 0;

通常,它会起作用,导致“评论”行显示出来。我不知道为什么,但是现在,我创建的每个新帖都没有“评论”和“分享”这一行。所以,这是我从https://graph.facebook.com/?ids=http://www.example.com/title-of-the-post/

得到的

旧帖子:

{
   "http://www.example.com/title-of-the-post/": {
      "id": "http://www.example.com/title-of-the-post/",
      "shares": 6,
      "comments": 6
   }
}

新帖子:

{
   "http://www.example.com/title-of-the-post/": {
      "url": "http://www.example.com/title-of-the-post/",
      "type": "website",
      "title": "Title of the post",
      "image": [
         {
            "url": "http://www.example.com/thumb.png"
         }
      ],
      "description": "This is a great post about great things.",
      "updated_time": "2012-12-25T17:57:03+0000",
      "id": "66666666666666"
   }
}

“评论”行不再显示,我现在有更多信息(一些我不在乎的信息)。所以发生了什么事?我根本没有改变我的代码!顺便说一下,我的评论框仍在工作并显示所有评论(而我的按钮显示正确的“份额”计数)。有人可以帮帮我吗?

2 个答案:

答案 0 :(得分:5)

对我来说看起来像个错误。 FQL查询是一种仍然有效的替代方案。这是一个例子:

select comment_count, share_count, like_count from link_stat where url = "http://techcrunch.com/2011/04/12/facebook-comments-now-on-over-50k-sites-get-more-social-with-latest-upgrade/"

在此处试用API资源管理器:http://developers.facebook.com/tools/explorer/?fql=select%20comment_count%2C%20share_count%2C%20like_count%20from%20link_stat%20where%20url%20%3D%20%22http%3A%2F%2Ftechcrunch.com%2F2011%2F04%2F12%2Ffacebook-comments-now-on-over-50k-sites-get-more-social-with-latest-upgrade%2F%22

但是,如果他们更改Graph API以再次返回共享计数和评论计数,我会很高兴。

这个官方Facebook文档(developers.facebook.com/docs/reference/plugins/comments/)仍然建议使用Graph API进行评论计数,但它似乎不适用于这样的新页面:{{3 }}

答案 1 :(得分:1)

Facebook弃用了FQL。所以,不要使用fql。您可以使用以下路径获取份额数

http://graph.facebook.com/?id=http://sriraman.in/

有关详细信息,请参阅http://blog.sriraman.in/url-share-count-facebook-twitter/

相关问题