Reputation: 2879
When getting a post comments list using POST_ID/comments, each comment contains a Boolean field named "user_likes" that tells me if the user likes the comment or not (this is how i decide which button to display like/unlike).
When getting the list of posts the post itself does not contain this field. I can still post to POST_ID/likes and DELETE to this address to change the like state, but there is no indication of the current state of the like.
Am i missing something? Is there an other way to determine the like state of the post?
Upvotes: 3
Views: 6051
Reputation: 2294
If you query the posts using /me/feed (for example) you can influence what fields are returned by adding the "fields" query param. In this case you can use "likes". This contains an array with all likes. You have to check if the user is a member of this array. The returned data by the FQL-variant mentioned by TommyBs is a little prettier (as often with FQL) though.
Example: /me/feed?fields=id,likes will return all posts ids and who liked them.
Upvotes: 1
Reputation: 9646
You could query the FQL "likes" table for the particular user or the object id in question.
https://developers.facebook.com/docs/reference/fql/like/
Alternatively (I'm guessing you have read_stream permission here) you could query the following table
https://developers.facebook.com/docs/reference/fql/stream/
Using the graph api explorer try running this query
make sure you grant the read_stream permission! There are obviously more fields you could retur as well, and you can replace "me()" with a different user_id, but then you might need to use the app access token
Upvotes: 0