Facebook get like count for search query - facebook

I'm using https://graph.facebook.com/search?q=watermelon&type=post to retrieve posts with query watermelon. Is it possible to also get the like count for the posts I retrieve?

The likes element is returned for search result entries that have been liked. Not all posts have been liked or the users permissions don't allow viewing of likes. Here is a screenshot from the graph explorer though for your query which has some likes information:

The Facebook FQL does not have the feature of count, but you could always count the number of objects in the array with whatever language you are using.

Related

Facebook Graph API - Getting time of the 'Like'

I am trying to get the time of the 'Like' using facebook api
https://graph.facebook.com/v2.5/feed?fields=likes{id,created_time}&access_token=MY_ACCESS_TOKEN
It works for comments but not for likes
https://graph.facebook.com/v2.5/NFL/feed?fields=comments{id,created_time}&access_token=MY_ACCESS_TOKEN
The documentation is also not consistent and doesn't give any details about this i.e. there are other fields for the 'Likes' edge such as 'profile_type', 'pic' etc... that show up in the Graph API Explorer but not documented.
The docs are actually consistent if it does not work for likes. The likes edge returns a list of Users, but the User table (obviously) does not have a field for the like time. The comments edge returns a list of comments, they do have a created_time field: https://developers.facebook.com/docs/graph-api/reference/v2.5/comment/

How to get all people who liked Facebook post?

I have FB post
I can click "77 people like this" and get all people I needed.
Question: is there way to get these people by FB API ?
PS I want to get 3 random names from these list so I need to have these people in JSON format
It's easy to do with FQL. This gets you three random ids of people who liked this event
SELECT user_id FROM like WHERE object_id = 336638873112346 ORDER BY rand() LIMIT 3
If you wanted to get their names instead, you'd rewrite the query like this:
SELECT uid, name, username FROM user WHERE uid IN
(SELECT user_id FROM like WHERE object_id = 336638873112346 ORDER BY rand() LIMIT 3)
I'm one of the co-founders of Kither, a platform for checking all of your Facebook stats. We have added many features which requires to fetch all of our user's posts likes.
As of August 6, 2016, FQL is deprecated.
Facebook's Graph API's still available and you can call https://graph.facebook.com/{api-version}/{post-id}/likes to get likes on posts. But remember, Facebook uses pagination on likes if there are more than 1,000 of them.
Now, In this case you'll need to call the next page url.
You'll need to call the next url unless you've got all the likes. (you won't find any next field if there are no more likes)
To get how many people have liked that post (i.e. count), you don't need to page through results. You can simply use https://graph.facebook.com/{api-version}/{post-id}/likes?summary=true and you'll get an extra field containing all likes' summary, including their count.
Same can be done with comments and recently added, reactions.

Get Facebook Page Feed and their likes/comments without any permissions

I am trying to get the user ids of all the users who have liked or commented on a status on a facebook page.
I tried using graph.facebook.com/page_id/posts?access_token=...
but it only gives me 2-4 user ids who have liked and their total count, similarly for comments. Is there any way to get all the ids?
According to The Documentation for the 'Post' object
(and verified by me on my own page using the Graph API Explorer tool), these work:
/POST_ID/comments to fetch the comments
/POST_ID/likesto fetch the Likes

Trouble with FQL stream_tag

I am trying to retrive posts from a users news feed in which my fan page has been tagged. I'm seaching through stream_tag with FQL but zero results are returned.
Posted a comment on my wall in which I tagged a friend, myself, and my fan page.
Used the Graph API Explorer - developers.facebook.com/tools/explorer/
Used the explorer as one of my apps, and granted every type of permission.
Did the following query:
https://graph.facebook.com/fql?q=SELECT post_id,actor_id FROM stream_tag WHERE target_id = [fan page id]
The following is returned: data: []
This seems to indicate that there is no resaults but I know the tag exists. When I do a query with target_id=me() results are returned, but according to the documentation the target_id can also be a fan page( http://developers.facebook.com/docs/reference/fql/stream_tag/ to craft the query).
How can I create a query that returns posts my fan page is tagged in?
I was trying to do the exact same thing when I came across your post. It looks like there currently is a bug report open that the stream_tag table does not work with when the target is a page.

How to know how many users "like" something [facebook]

How to get how many times specific object was liked?
Answer: http://developers.facebook.com/docs/reference/fql/link_stat
and
How to get the most liked links in my application?
UPD 3: another question then: how to get the object_id for given liked page
Answer: object_url fql table
You can use a SQL (FQL) query and then count the users who liked the object. Heres information on the query: http://developers.facebook.com/docs/reference/fql/like