How to detect fan in facebook canvas page

facebookSometimes you may need to check whether logged in user or a particular user is a fan of a facebook page or not. If you want to detect facebook fan in facebook page then checkout my previous article How To Detect Fan Of A Facebook Page

But if you want to detect facebook fan in a canvas application then there is a simple api to check that:

include_once "facebook.php";
$facebook = new Facebook($api, $secret);
//check whether logged in user is fan of
$isFan      =   $facebook->api_client->pages_isFan(314110374728);

//check whether 123456789 user is fan of
$isFan      =   $facebook->api_client->pages_isFan(314110374728, 123456789);

if ($isFan){
   echo "User is a fan of '' ";

Here the first parameter is page id and second parameter is uid. If no uid is provided then this api used the logged in user id. This api doesn’t work for application about pages.


mahmud ahsan

Computer programmer and hobbyist photographer from Bangladesh, lives in Malaysia. My [Github | Business | Twitter | Linkedin | Youtube | Instagram | 500px]

You may also like


  • quok
    July 13, 2010 at 9:25 pm

    hey there … thanks for the tip.

    But i can´t get that to work with the recent facebook php sdk. Seems like they changed a lot with the last release.

    Have you tried with the new sdk ?


  • quok
    July 14, 2010 at 7:36 pm

    hey mahmud .. thx for the quick reply but i still can#t get it working like i want it.

    you example works fine (btw. thanks for this great tutorial) and with the workaround of emran ( i was able to create an automatic redirect on the login url.

    What i would like to do is to check the Fan status of a user in a profile tab.
    is it possible to check the users fan status in a profile tab without redirecting him ?

    thanks a lot

  • Puzbie
    November 13, 2010 at 7:14 am

    Quok, did you ever work out how to do this?

    I have a PHP application which I want to run in a tab on a fan page.

    If I call

    $me = $facebook->api(‘/me’);

    I don’t get any info about the logged on user. Instead I get information about the app itself. How do I determine:

    A) Who the logged on user is.
    B) Whether they like the fan page.

    Great tutorials btw.

  • jaarek
    December 16, 2010 at 2:39 pm

    Hi, I used your code, and it doesn’t work, I’m using new php-sdk, can you show us a new example of it?

    thanks for all tutorials;)

  • Sergey
    December 21, 2010 at 11:39 pm

    Hi Mahmud,
    Is it possible to know using Graph API Who like some page?

Comments are closed here.