To check whether a particular user likes your Page or App, you can use this Graph API call /me/likes, after the user is logged in to your application. You need the page id or application id to check against.
Your application also needs to have an extended permission named user_likes to retrieve a list of user Likes. Read about this permission here: http://developers.facebook.com/docs/authentication/permissions/.
Without this permission you can still query user likes but only if the user has set user_likes preference to be accessible to public.
The above setting available at: (Account->Privacy Settings->Connecting To Facebook section -> View Settings)
 
In a nutshell, here’s what you need to do:
First, call the /me/likes API.
FB.api('/me/likes', onLikeCheckResponse);
Then, check the response.data array and compare the data.id with your application or page id.
for (var i=0; i<response.data.length; i++) { if (response.data[i].id=="163504083699380") { alert("You like this app."); return; } }
In this example, 163504083699380 is my application id. I then iterate every user Like and check their id against my application id. If my application id is found on the list, then I know that the user likes my page.
function onLikeCheckResponse(response) { // Iterate and check against your id for (var i=0; i<response.data.length; i++) { if (response.data[i].id=="163504083699380") { alert("You like this app."); return true; } } alert("You didn't like this app."); return false; } function checkLike() { FB.api('/me/likes', onLikeCheckResponse); }
Example:
- Link to the bare-bone example: /tutorial/facebook-like-check/index.html.
- Further explanation of the login setup (not required if you already familiar with setting up Facebook Connect login process): /blog/2010/11/facebook-open-graph-api-authenticating-in-iframe-applications/
IMPORTANT UPDATE
:
As of 12/16/2011, there have been the following changes to the Facebook API:
- response.session is now called response.authResponse. So, anywhere you see response.session, replace it with response.authResponse.
- perms is now called scope. So, anywhere you see perms, replace it with scope.