Friday, 9 November 2012

Facebook Login on your website using Javascript and showing all user details

This script
- uses Fb Api in javascript to authenticate on your website.
- pulls the user details from its Facebook account and displays the same on your webpage.
- has Fb logout facility.

Download Pack     Live Demo    

How to use:

The download pack contains an HTML file named FbLogin.html and a Javascript file called FbLogin.js
You need to create a Facebook app and specify your website that requires a Facebook login.
Also note the App Id for your Fb app.


In the config section of the Javascript file, set the value of fbAppId variable to the app Id you noted from the Fb App.
The output variables will be available in the javascript if you need to use them.

My JS function displayUserDetails() uses the output variables and displays them on the HTML.
You may write your own function instead, as required.

Let me know if you face any issues.

1 comment:

  1. Thanks for the script!
    Just note that currently it throws a js error.
    To fix it replace:
    "hometown =;" with "hometown = user.hometown;"
    "current_location =;" with "current_location = user.location;"