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)
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
- Open https://developers.facebook.com/apps/
- Click Register Now Button
- Enter you details and give you app name & app url
- Once the app created, you will be redirected to like below screenshot
- 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.
- Create the database name, Ex: facebooklogin
- You can find users.sql from downloaded source code and import the file in facebooklogin database.
- 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.
Please share and comment