Setting Up FB Login with PHP

Main Ref
Another ref
Ref for Login with DB

Facebook login manual flow

Facebook tutorial for login with JS

Full JS reference

  1. Create FB App

Created App

  1. Under Settings >> Basic

    • set App domains
    • get App Id and App secret
  2. Download facebook graph sdk

Graph SDK Git

composer require facebook/graph-sdk
  1. copy index.php and profile.php
  2. replace App Id, App secret and OAuth Redirect URI
  3. Under Products >> Facebook Login >> Settings
    set Valid OAuth Redirect URIs

Test Operations

Get albums

ref

Possible Errors

  1. Facebook OAuth "The domain of this URL isn't included in the app's domain"

Under Products >> Facebook Login >> Settings

set Valid OAuth Redirect URIs

  1. This app is not currently accessible and the app developer is aware of the issue. You will be able to log in when the app is reactivated.

    • Check if app_id and app_secret is correct.
    • Check if the user is added as Administrative or Development Contact
  2. Facebook SDK returned an error: Cross-site request forgery validation failed. The "state" param from the URL and session do not match

Check wether all required $_SESSION vars are set and session_start() is called.

  1. During testing it shows "there is some problem with the app"

    • you might have set permission for something eg: email, but it is not set in app admin of developer page. in the Use Cases page of facebook developer page of app. add email in Authentication and account creation
  2. During testing , i added another user as administrator and tried to access the app, it shows app is still under development.

    • you might have added the user as administrator. But that user also needs to acknowledge and approve it clicking the notification.
  3. URL Blocked: This redirect failed because the redirect URI is not whitelisted in the app’s Client OAuth Settings. Make sure Client and Web OAuth Login are on and add all your app domains as Valid OAuth Redirect URIs.

    • Properly set App Domains in Settings >> Basic and OAuth URLs under Under Products >> Facebook Login >> Settings