Facebook PHP Sdk return redirect uri is required -
i trying authenticate using facebook php sdk returning error
the parameter redirect_uri required
you can see in url above redirect_uri present value.
here code using
config.php
<?php //configure app here define("app_id","abcd");//replace facebook app id define("app_secret","abcd");//replace facebook app secret define("callback_uri","https://example.com/callback.php");//replace callback url [this facebook redirect user after login] define("logout_redirect_url","https://example.com/close.php");//replace url of login page /** app configuration end here **/ //no need change below 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 access $loginurl = $helper->getloginurl(callback_uri, $permissions); //$loginurl = '<a href="' . htmlspecialchars($loginurl) . '">log in facebook!</a>'; $loginurl = htmlspecialchars($loginurl); header("location: $loginurl"); exit(); ?>
the '&'
within url not accepted. must & instead.
Comments
Post a Comment