I'm using the facebook comment plugin for my blog and until now, the facebook graph api helped me to retrieve the comment count of each post on my website. So, as I said, the posts that I've written like a month ago, I can retrieve the comment count using php and json_decode like this:
$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;
Usually, it works cause the "comments" line show up. I don't know why, but now, every new post that I create don't have the "comments" and "shares" line. So, here's what I get from https://graph.facebook.com/?ids=http://www.example.com/title-of-the-post/
Older post:
{
"http://www.example.com/title-of-the-post/": {
"id": "http://www.example.com/title-of-the-post/",
"shares": 6,
"comments": 6
}
}
New post:
{
"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"
}
}
The "comments" line doesn't show up anymore and I have more information now (some information that I don't care). So, what happened? I didn't change my code at all! By the way, my comment box is still working and display all the comments (And my like button display the "shares" count correctly). Can somebody help me?
Looks like a bug to me. FQL Query is an alternative that still works. Here's an example:
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/"
However I would love it if they changed the Graph API to return share counts and comment counts again.
This official Facebook doc (developers.facebook.com/docs/reference/plugins/comments/) still recommends using the Graph API for comment counts, however it does not seem to work with new pages like this one: https://graph.facebook.com/?ids=http://techcrunch.com/2012/12/27/the-last-imac-question-mark/
Facebook deprecated FQL. So, Don't use fql. You can get the number of shares using the following path
http://graph.facebook.com/?id=http://sriraman.in/
For more information, Refer, http://blog.sriraman.in/url-share-count-facebook-twitter/
来源:https://stackoverflow.com/questions/14061877/facebook-graph-api-url-comments-and-shares-count-doesnt-work-anymore