Facebook Graph API - Getting time of the 'Like' - facebook

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/

Related

Facebook graphapi page/feed returning items sorted by relevance instead of recent activity

Hi I am using the Facebook graph api tool and attempting to get the feed of a public page. I want to get most recent comments first. However the feed returns comments and replies sorted by "relevance", is there a "sort" I can apply or how do I change this to get recent comments and replies within my posts?
I do not own the page I am getting the feed from.
There's the order parameter for comments, which can have the following values:
chronological
reverse_chronological
See
https://developers.facebook.com/docs/graph-api/using-graph-api/v2.5#ordering
As far as I know, the feed's posts will always be sorted by created_time, and there's no way to influence this via the Graph API requests.

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)

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.

Facebook get like count for search query

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.