Login with Facebook using PHP SDK

Login with Facebook is a quick and powerful way to integrate registration and login systems on the web application. Facebook is the most popular social network and most of the users have a Facebook account. In this tutorial, you will learn how to build a Login with Facebook using PHP SDK. You can also download the source code of the live example.
So let’s implement Login with Facebook using PHP. look files structure:
  • login-facebook-app
    • callback
      • facebook
        • index.php
    • vendor
    • index.php
Create an app on Facebook
First, you log in Facebook Developer Console. Because when you create an app in the Facebook Developer Console. Then Facebook provides you with some appID and Secret key. With the help of which you can integrate and implement Facebook Login.
Step 1 – Create Facebook App
The following url https://developers.facebook.com/apps and create a new Facebook App.
Step 2 – Create a Facebook app
Create a Facebook app with email and app name:
Step 3 – Advanced Setting
Goto Setting >> Advanced and add redirect URL:
Step 4 – Add valid auth URL
Add valid auth redirect URL. So, click Facebook Login >> Setting and add valid auth redirect URL:
Step 5 – Get App ID and SECRET details:
Go to the Facebook developer dashboard and copy the following App ID and App SECRET:
Step 6 – Install Facebook PHP SDK
Install facebook PHP SDK So, Open your command prompt and go to your web application directory and execute the below-given command to install Facebook PHP SDK:
Step 7: Create index.php file
Now on the callback page, we check the user and set session if the user has an account on Facebook.
Step 8: Create index.php file inside folder name “callback/facebook”
Show logged-in user information like Facebook id full name, email, picture, and more