Getting the number of Facebook likes for a URL - facebook

I know there are several related answers on SO, but none seem to answer my question.
I would like to know if there is way to get the number of likes for a URL, using Graph API 2.2.
I know how to obtain this info via FQL or REST API, but those are deprecated.
https://graph.facebook.com/?ids=some_url
This returns the number of "shares", which is a total of like + shares + whatever. I need only the number of likes.
https://graph.facebook.com/some_opengraph_id/likes?summary=true
This returns the number of likes, but that total seems to be much lower than what a query on FQL link_stat table would return. Also /likes returns a list of likes, but it doesn't seem to be a complete list.
So is it possible to do this via Graph API or only FQL / REST support this?
Thanks in advance!

I encountered the same behavior, but unfortunately afaik there are no other options currently. If you have a v2.0 app, you can continue to use FQL until August 7th, 2016.

Related

Count facebook page posts likes

I was reading the fb api doc but I couldn't find a lot about the different type of queries you can build.
Im trying to count all the likes in the posts from certain facebook page of the day.
Does the API supports params like the date or Will I have to take a whole response like the one I get with this request and somehow sum the counts of the likes?
https://graph.facebook.com/PAGE_ID/feed?fields=comments.limit(1).summary(true),likes.limit(1).summary(true)&access_token=XXXXXXX
Thanks
most graph api queries support a since, until params
you can try this based on your example
https://graph.facebook.com/PAGE_ID/feed?fields=comments.limit(1).summary(true),likes.limit(1).summary(true)&access_token=XXXXXXX&since=2015-08-25&until=2015-08-26

facebook - Get article likes, shares and comments without FQL

Is it possible to get like-, share- and comment counts for an article (or other open graph object) without using FQL?
I'm aware that API v2.1 introduced the URL node which includes two fields called 'share_count' and 'comment_count'. But these are not the same values as the ones you get through FQL.
'share_count' appears to be the sum of likes, comments and shares.
'comment_count' appears to be a different value entirely, possibly comments published through the Comments Box plugin.
For a comparison, see the following links. (I'm unable to make the FQL query in Graph API Explorer for some reason.)
Old
New
Since API v2.0 will eventually expire, I'd rather not develop apps based on this version. But right now, I don't see any way of getting like-, comment- and share metrics for articles. I'd like to retrieve these metrics because they are more detailed than the new 'share_count' value.
Any ideas?
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.

getting user likes in facebook

I am trying to get user likes in facebook. I can only get 100 at a time for some reason. i tried using the limit parameter in open graph syntax and it didn't help. I alwso tried writing an FQL query to get more likes and to no avail. No matter what I do, i get only 100 likes per request. It's even worse. Most of the likes are of no interest to me. I'm using only likes on several categories. if i could have gotten (using FQL) 100 likes of a user which are all of those categories, that would have been sufficient to me. But when I call the FQL query it seems that FB is querying on 100 first likes and returning the results instead of returning 100 results. I am despaired at this mechanism, is there a way out of this or is FB really gave no way to get more likes in a single call?
Read about paging in the docs: https://developers.facebook.com/docs/graph-api/using-graph-api/v2.2?locale=en_GB#paging
I guess the max limit is 100, if you want to get more than that you have to make another call by using paging. There is no way to filter with the API, you will have to do that on your own after getting the likes.

How to count likes/comments of a photo/post using new Facebook Graph API 2.1?

I tried for several hours to get the total number of likes/comments of a photo/post using the new Facebook Graph API 2.1 but I didn't find how to do it.
I am able to photo and post details through the API but it contains only an subarray with some likes and comments (ID/Name pair), but no the total number. Graph API Reference for object/likes mention a total_count field but is not able to found in API response.
Can you please suggest me a way to do it?
I am using latest Facebook PHP SDK 4.
I faced this situation before. Facebook Graph API Explorer, in the Fields dropdown list, you can not find any field related to total_like or total_comment of a specific post ( via its object_id). That means Facebook Graph API does not support getting the total likes, comments of a specific post.
But, it support to get likes, comments data of a post via likes, comments fields. So by this way, you can get the entire data about likes, comments, therefore, you can get the total number of likes/comments. This solution is not good, I think. I think in the near feature, Facebook Graph API support the fields total_likes, total_comments.
/object_id?fields=comments.limit(1000),likes.limit(1000)

Facebook - check who shares a link

When I type name of e.g. youtube clip in facebook search I can get number of people that share this link.
Is it posibble to fetch list of people sharing given like using facebook api?
No, you can't get who shared, only the total number. The easiest way to see the count is, for instance:
http://graph.facebook.com/http://stackoverflow.com
This solved my problem !
http://graph.facebook.com/http://stackoverflow.com
Creating Facebook apps was very easy, but now, you need to apply and ask for approval the app ... that sucks ...
You can do this with Facebook's FQL (Facebook Query Language), it gives you more information than the previously mentioned Graph API method, but Facebook are apparently going to turn off the FQL API on August 7, 2016. So its not going to be useful in the long term.
https://api.facebook.com/method/fql.query?query=select+comment_count%2C+like_count%2C+total_count%2C+share_count%2C+click_count+from+link_stat+where+url%3D%27stackoverflow.com%27
The interesting thing about this is it shows the result given by the previously mentioned Facebook Graph API request, i.e:
http://graph.facebook.com/http://stackoverflow.com
is actually giving the "total count", which is actually the sum of the likes, comments and shares of that link, the FQL method gives you the actual individual counts for comments, shares and likes.
Another method for getting the actual share count, is to use the links.getStats API call, but it appears to be undocumented, and nobody seems to know how long it will be available for.
Here's how to use it:
https://api.facebook.com/method/links.getStats?urls=stackoverflow.com&format=json