Login with Facebook Account using PHP

Login with Facebook Account using PHP

In this article, We will explain how to create a login with Facebook account using PHP. Here we will create a system where the user can log in with his Facebook account on your website. So, in this post, we share a tutorial on how to login or sign in or sign up with a Facebook account in your PHP web application.

To login with Facebook account using PHP, Facebook PHP SDK has provided Facebook OAuth API, which is very easy and useful to implement login using a Facebook account on your website. The Facebook login product provides rights to the user to login to the website using their Facebook account credential without registering on that particular website.

In this example, we will use the Facebook PHP SDK library, this library gives users permission to sign in with their existing Facebook accounts on your website. Below, you can find how to integrate Facebook login API into your PHP website and you can also find the process of how to get Facebook API id and how to integrate the Facebook SDK library into your existing PHP library to login.

Create Facebook App

Now we need to app id facebook and App Secret for Facebook login. first we have to create the Facebook app. so you can see below steps.

  • First login with your Facebook account and Goto Facebook for Developers page https://developers.facebook.com/apps/
  • click on My apps menu at the top navigation bar and click on Create App link
    • select app types
    • Enter the App Display Name and App Contact Email.
    • Click on the Create App button.
  • In the right sidebar menu, navigate to Settings > Basic menu
    • Add App Domains and select the Category of your App.
    • Click the Save Changes.
  • In the right sidebar menu, navigate to the Add a Product
    • Select Facebook Login product.
    • select the web platform.
    • Enter the Site URL and Save.
  • In the right sidebar menu, navigate to the Facebook Login > Settings menu.
    • Add Valid OAuth Redirect URIs field
    • Click the Save Changes.
  • In the right sidebar menu, navigate to the Settings > Basic menu.
    • get App ID and App Secret

php_facebook_login

Install / Download Facebook SDK for PHP

After we got the Facebook app id and Secret key, now we need to download the Facebook Sdk for PHP library. For this, we need to go to the command prompt and first type the command composer, after that, we need to run the following command.

Facebook API configuration and set variables

config.php
now, first, we need to create a config.php file. after that, we will configure the Facebook app id and secret key and add the Facebook SDK library in this file.

index.php

delete.php

Read Also

Login With Google Account Using PHP

PHP Login And Registration Example

Login And Registration Example Using Pdo

Download

Please follow and like us: