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>';
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.