Reputation: 1569
I am trying to authenticate using facebook php sdk but its returning error
The parameter redirect_uri is required
You can see in the url above the redirect_uri is present with its value.
Here is the code i am using
Config.php
<?php
//CONFIGURE YOU APP HERE
define("APP_ID","abcd");//REPLACE THIS WITH YOUR FACEBOOK APP ID
define("APP_SECRET","abcd");//REPLACE THIS WITH YOUR FACEBOOK APP SECRET
define("CALLBACK_URI","https://example.com/callback.php");//REPLACE THIS WITH YOU CALLBACK URL [This is where facebook will redirect user after login]
define("LOGOUT_REDIRECT_URL","https://example.com/close.php");//REPLACE THIS WITH URL OF YOU LOGIN PAGE
/** APP CONFIGURATION END HERE **/
//NO NEED TO CHANGE BELOW ANYTHING
require_once('facebook-php-sdk-v4-5.0.0/src/Facebook/autoload.php');//LOADS FACEBOOK SDK
session_start();
$fb = new Facebook\Facebook([
'app_id' => APP_ID,
'app_secret' => APP_SECRET,
'default_graph_version' => 'v2.5',
]);
?>
login.php
<?php
require_once('config.php');//Loads configration
$helper = $fb->getRedirectLoginHelper();
$permissions = ['email']; // PERMISSIONS YOU WOULD LIKE TO ACCESS
$loginUrl = $helper->getLoginUrl(CALLBACK_URI, $permissions);
//$loginUrl = '<a href="' . htmlspecialchars($loginUrl) . '">Log in with Facebook!</a>';
$loginUrl = htmlspecialchars($loginUrl);
header("location: $loginUrl");
exit();
?>
Upvotes: 0
Views: 4018
Reputation: 1
I had the same issue but I figured out my: $facebook = new Facebook\FacebookRedirectLoginHelper(URL) was different from what I had in my developers.facebook site.
Upvotes: 0