Is there anyway to determine if an object in Open Graph has been liked?
The documentation seem to imply that I have to post a like action on my object and expect an Error 3501 when it has been liked before.
From an UI pov this doesn’t make sense, I want to change my like button ui to an “unlike” state without having to like my object and see if it fails or not.
Thanks!
If you’re looking specifically for likes on an Open Graph
Object(as in the target of an Open GraphAction), and you’re talking about built-in (og.likes) likes, Shawn’s answer is mostly right, but you need to look in a different FQL table.An Open Graph
Objectis just a URL that resolves to a page that hasog:typemeta in its header. Facebook treats these aslinkobjects (you can check this withSELECT type FROM object_url where url='http://url.to/your/object')You can find interesting information in the link and link_stat FQL tables, but what you’re looking for is the join table where Facebook relates user likes to links: the url_likes table.
So, to tell if the current user has liked a given Open Graph
Object, you’d use:If you get a value back, the current user has already liked it. If you get an empty array, the current user has not liked it.
To my knowledge, there’s no way to do this with the Graph API, only FQL. I’d love to be proven wrong, though.