PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Saturday, February 26, 2022

[FIXED] Login using Facebook-PHP-SDK

 February 26, 2022     facebook-php-sdk, php     No comments   

Issue

Very new to php and I am trying to figure out how to use Facebook-PHP-SDK. I set up an account on Facebook Developers and am trying to get data from my own Facebook, which I have linked to my developer account. I am trying to implement the following practice code but I am confused about the login URL. Am I suppose to put my own Facebook URL for that? Or something else?

Practice Code

session_start();
$fb = new Facebook\Facebook([
  'app_id' => '{app-id}', // Replace {app-id} with your app id
  'app_secret' => '{app-secret}',
  'default_graph_version' => 'v3.3',
  ]);

$helper = $fb->getRedirectLoginHelper();

$permissions = ['email']; // Optional permissions
$loginUrl = $helper->getLoginUrl('https://example.com/fb-callback.php', $permissions);

echo '<a href="' . htmlspecialchars($loginUrl) . '">Log in with Facebook!</a>';

Solution

You should put in the login url the link of the file content your code: example, this mean the file who contains the current code:

$loginUrl = "http://localhost/login.php"

and the https://example.com/fb-callback.php must redirect to a (file/url) in your application to verify the authentication and extract the access token for example.



Answered By - Soufiane Lamnizeh
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing