Facebook Chart - Does the user "like" my page?

I am trying to update my iPhone app to use the new facebook api graph. One thing I can't seem to find is to figure out if the current user connected from my app to facebook is a fan of my facebook page - (i.e. in the new paradigm - do I like my page)

Rest Api had isFan function, but not in graph.

I can get all the elements the user likes and search to see if one of them is my page, but of course there should be an easier way, not going through thousands of entries every time I have to check if he is a fan. right?

If anyone has already figured out how to do this from their new docs, I would really appreciate it if you would share it with me.

+2


a source to share


5 answers


According to Facebook Dev docs, the old pages.isFan

method has an equivalent in the graphics API now

Please note that we are in the process of canceling the REST API and have added equivalent Graph API support for this method. You can now issue an HTTP GET request to / USER_ID / like / PAGE_ID to check if the user is a fan page.



Accordingly, the call / {User ID} / likes / {PAGE ID} will return the necessary information if you have a valid ( user_likes

) Permission or the user likes the public

+6


a source


What you are looking for is a join table. Try the following:

SELECT target_id, target_type
FROM connection
WHERE source_id = '_THE_USERS_FACEBOOK_ID_'
  AND target_id = '_THE_ID_OF_THE_PAGE_OR_OBJECT_TO_LIKE_'

      



This is an FQL statement that can be run from the JavaScript FB.api method or through any of the SDK files.

0


a source


The fastest and easiest solution if you are parsing the $ _POST variable when your page is called by Facebook. The signed_request has information (also) whether the user likes your page or not, even he / she has not yet granted access to your application.

0


a source


With the PhoneGap plugin, I can do this:

pageID = '6815841748';
FB.api('/me', function (a) {
   user_id = a.id;
   FB.api('/' + user_id + '/likes/'+pageID, function (a) {
        alert(a.data.length);
    })
});

      

It will return 1 if they like the given page id, 0 otherwise.

I discovered (but not tested) a possible cleaner method:

window.checkDoesLike = function() {
  FB.api({ method: 'pages.isFan', page_id: '6815841748' }, function(resp) {
    if (resp) {
      alert('You like.');
    } else {
     alert("You don't like.");
    }
  });
};

      

0


a source


Right now, the graph resource "// like" is the only one available. It's not so bad.

https://graph.facebook.com/ngerakines/likes?access_token=

      

-2


a source







All Articles