How To Get Facebook User ID, details of User in Iframe Page Tab?
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: https://github.com/facebook/facebook-php-sdk. Extract the following files from the src folder in the SDK and put it in the application root:
Now sign-up for a Facebook Developers account and create a new Facebook App. You can do this from here - https://developers.facebook.com/apps. 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.
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.
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.
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: https://www.facebook.com/digitizormedia/app_482126891854051
Listed below are codes for same. If you have any issues do let us know in the comments section: