How to Fetch Facebook Likes, Share, Comments Count from an Article

How to fetch facebook likes, share, comments count from an article

Actually you can have a more detailed report using FQL.
Try following query:

  • SELECT url, normalized_url, share_count, like_count, comment_count, total_count, commentsbox_count, comments_fbid, click_count FROM link_stat WHERE url = 'www.apple.com'

Here the php code:

$fql  = "SELECT url, normalized_url, share_count, like_count, comment_count, ";
$fql .= "total_count, commentsbox_count, comments_fbid, click_count FROM ";
$fql .= "link_stat WHERE url = 'www.apple.com'";

$apifql="https://api.facebook.com/method/fql.query?format=json&query=".urlencode($fql);
$json=file_get_contents($apifql);
print_r( json_decode($json));

And this is the expected result:

Array
(
[0] => stdClass Object
(
[url] => www.apple.com
[normalized_url] => http://www.apple.com/
[share_count] => 355693
[like_count] => 500374
[comment_count] => 290890
[total_count] => 1146957
[commentsbox_count] => 2
[comments_fbid] => 388265801869
[click_count] => 16558
)

)

How to get facebook share, like, comment count for a url with graph api only (in a non-deprecated way)

The REST API (with calls like http://api.facebook.com/restserver.php?method=links.getStats&urls) was announced as deprecated with the introduction of the Graph API v2.1: https://developers.facebook.com/docs/apps/changelog#v2_1_deprecations but also already in 2011: https://developers.facebook.com/blog/post/616/

So, from my understanding, this will yield in the inoperability of this feature at two years after the introduction of v2.1 on 7th August 2016:

https://developers.facebook.com/docs/apps/versions#howlong

The closest you can get to the "old" REST of FQL API call results with the Graph API is this afaik:

https://developers.facebook.com/docs/graph-api/reference/v2.3/url/

but it omits the like_count metric (don't ask me why...).

My personal opinion is that you should continue to use the FQL calls to the link_stat (https://developers.facebook.com/docs/reference/fql/link_stat/) table, because this will be available for nearly the next 2 years. This is only possible if you have a v2.0 app. Maybe there'll be some additional endpoints for the Graph API until then.

Facebook App, counting likes, shares and comments

It can be accomplished using the Graph API

http://graph.facebook.com/?id=YOUR_URL

something like:

http://graph.facebook.com/?id=http://www.yahoo.com

A sample of the returned values would be:

{
"id": "http://www.yahoo.com",
"shares": 200

}

You can get the following information with the like button

The number of likes of this URL
The number of shares of this URL
The number of likes and comments on stories about this URL

The Like Button number is possible with the Graph API through the fql end-point (the link_stat table)

Here is a sample of the call URL to submit:

 https://graph.facebook.com/fql?q=SELECT url, normalized_url, share_count, like_count, comment_count, total_count,commentsbox_count, comments_fbid, click_count FROM link_stat WHERE url='http://www.yahoo.com'

facebook - Get article likes, shares and comments without FQL

At present using link_stat FQL on v2.0 is the only option to get the drill down that you are looking for

https://developers.facebook.com/docs/reference/fql/link_stat

SELECT like_count, comment_count, share_count,total_count FROM link_stat WHERE url = 'google.com'; 

"data": [
{
"like_count": 3385562,
"comment_count": 2034401,
"share_count": 7514540,
"total_count": 12934503
}]

That breakdown isn't available via url or engagement https://developers.facebook.com/docs/graph-api/reference/v2.4/url https://developers.facebook.com/docs/graph-api/reference/v2.4/engagement

Maybe by the time FQL is deprecated there may be further endpoints that can give you the data.

How to get likes count from facebook graph api which is shared from my web app?

Check out the engagement field - https://developers.facebook.com/docs/graph-api/reference/v3.2/url

It returns four different counters - comment_count, comment_plugin_count, reaction_count and share_count.

The reaction_count would be the number of all reactions (like, love, sad, …) - that is as much “detail” as you can get in this regard for external Open Graph objects.

Example in Graph API Explorer, for the object http://example.com/:

https://developers.facebook.com/tools/explorer?method=GET&path=%3Fids%3Dhttp%253A%252F%252Fexample.com%252F%26fields%3Dengagement&version=v3.2

Facebook graph api comment count

To get the count, add ?summary=1 at the end: https://graph.facebook.com/125909647492772_502974003098530/comments?summary=1



Related Topics



Leave a reply



Submit