Facebook Graph Api check if a loggedin user likes a post

1.1k views Asked by At

I'm working on a app in which i need to check if the current logged In user liked a post from a particular page. So that i can show the appropriate like/liked button. (I don't want to get all the likes of a post and iterate over them)

Alternatively i could use the FBSDKLikeControl, but my problem is i want to show custom like/liked buttons.

2

There are 2 answers

0
Rafael Munoz On

Right now, there is not a direct way using the GraphAPI to know if a user has liked an specific post or not besides going through all the post likes: https://developers.facebook.com/docs/graph-api/reference/v2.3/object/likes

1
user1105951 On

use :

THE_POST_ID?fields=likes.summary(true).fields(name).limit(1)

And in the results check the "summary" dictionary you will get :

total_count,

can_like,

has_liked <----this

(tested with graph api 2.5)