You Are Here: Home » Facebook » How-To » Programming

How To Get Facebook User ID, details of User in Iframe Page Tab?

By Debjit on March 26th, 2013 

Facebook Fan Page tabs are a good way of marketing your brand or business right inside your Facebook page. In this article we will show you how you can access more details about a fan of your page, details like his Facebook ID, full name, email address, etc. The best part of this tutorial is that the user need not necessarily like your page in order to access their details. We are using Facebook's PHP SDK in order to implement our idea.

The first thing you need to is get the Facebook PHP SDK and put it in your application's root folder. Get it from here: Extract the following files from the src folder in the SDK and put it in the application root:

  • src/base_facebook.php
  • src/facebook.php
  • src/fb_ca_chain_bundle.crt

Now sign-up for a Facebook Developers account and create a new Facebook App. You can do this from here - After you create the App, you will come across two values required for the App - the App ID and the App Secret. Make a note of these as you will need them later in this tutorial.

Facebook App Details

Facebook App Details

Now go down the same page and click on Page Tab in order to enter more information about your Page Tab application. You need to enter both the secure and non-secure location of the apps. After you are done you can click on Save changes. At this point we are all sent and we can start writing the code.

Facebook Fan Page app details

Facebook Fan Page app details

The idea behind getting an User's Facebook details on your FB page is based on the fact that the user has to login to your app on your Fan tab. else the only information that we will be able to get from the tab is whether or not the user like your fan page.

Now, a user can log into your app in two ways, one via javascript and another via PHP. We have already discussed the Javascript way of doing it (  with you. Now we will show you the PHP way of doing it.

Create three files - config.php, index.php and redir.php. Config.php file will contain all the configuration related items. Index.php is our core code file and redir.php is needed to send uder back to the Fanpage tab after he is redirected from the App auth dialog.

You can try the live demo at:

Listed below are codes for same. If you have any issues do let us know in the comments section:


How To Get Facebook User ID, details of User in Iframe Page Tab? was originally published on on March 26, 2013 - 2:12 am (Indian Standard Time)