javascriptfacebookfacebook-graph-apifbjsfacebook-javascript-sdk

Checking action status of a Facebook Open Graph Object


Given the following call to post an action on an object, what is the code to determine whether a user has taken the action for said object? Switching "post" to "get" pulls all the user's actions (not just for the current obj), and replacing the first argument with the object's URL throws an error.


Solution

  • The scope of my intended question has changed, so this answer isn't 100% direct, but it's what I ended up using, and I think it could benefit future viewers.

    I use the following FQL query via the js sdk in order to find out if a specific user has liked a specific object. If they have, it will return an array with their id. If they haven't, it will return an empty array:

            FB.api({
                method: 'fql.query',
                query: 'select user_id from like where user_id=' + UserIDVar + ' and object_id=' + ActionIDVar,
                return_ssl_resources: 1
            }, function(response){
                console.log(response);
            });
    

    The FQL query can be modified to suit your needs, and the documentation can be referenced here: https://developers.facebook.com/docs/reference/fql/like/