Login the App using facebook oauth in PHP

In my old articles, we see integration about how to login the apps using social networking in PHP like Twitter, LinkedIn, Google Plus. In this tutorial, I’ll be sharing how to integrate Facebook login with oauth in PHP. Facebook is one of the biggest network and everyone using Facebook account. So now I have develop this article to integrate with oauth connection using PHP. Download the zip (*.zip)

DownloadGitHub

Before running the code we have to create Facebook App id. Follow the below steps to get one for you.

Create Facebook App id and Secret

First, you have to create one app id with facebook developer dashboard. Follow the steps

  1. Open https://developers.facebook.com/apps/
  2. Click Register Now Button
  3. Enter you details and give you app name & app url
  4. Once the app created, you will be redirected to like below screenshot
    facebook create app id screenshot
  5. Copy App ID and App Secret

Facebook OAuth Configuration with Source Code

Below steps will explain you how to setup the Facebook OAuth using the downloaded source code.

Database Configuration

  1. Create the database name, Ex: facebooklogin
  2. You can find users.sql from downloaded source code and import the file in facebooklogin database.
  3. Once the import is done, then we are done with database setup

Configuration and setup FB API in source code

We done with DB setup. Now we have to change the db name, fb appid and app secret in downloaded source code to run the code successfully. follow the below steps.

  • Open User.php file and replace the database name with the one you created
  • Open fbConfig.php file and change the FB appid and app secret id with one you have created

So we all set with configuration steps and we ready to run the code. Once you successfully configured you will see the page like below screenshot.

Allow user to login the page using facebook

Please share and comment

Categories:
W3TWEAKS
Latest posts by W3TWEAKS (see all)

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *