2012-12-27 54 views
3

我为我的博客使用Facebook评论插件,直到现在,facebook图表API帮助我检索了我网站上每篇文章的评论数。所以,正如我说的,我已经写了像一个月前的文章中,我可以使用PHP和json_decode这样检索评论数:Facebook Graph Api网址评论和分享数量不再有效

$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" 
    } 
} 

“注释”行不再出现了,我现在有更多的信息(一些我不关心的信息)。所以发生了什么事?我根本没有更改我的代码!顺便说一下,我的评论框仍在工作,并显示所有评论(和我喜欢的按钮显示“股份”计数正确)。有人能帮助我吗?

回答

5

看起来像一个bug给我。 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

但是,如果他们改变了图形API再次返回份额数和评论数我会喜欢它。

这位官方Facebook文档(developers.facebook.com/docs/reference/plugins/comments/)仍然建议使用Graph API进行评论计数,但它似乎不适用于像这样的新页面:https://graph.facebook.com/?ids=http://techcrunch.com/2012/12/27/the-last-imac-question-mark/

+0

非常感谢!它完美的作品! – pmrotule

相关问题