EDIT: I have http://www.example.com
(example being my live site) as the Site URL under basic settings. I also have www.example.com
and example.com
under App Domains.
The error I'm getting is:
The redirect_uri URL must be absolute
My code breaks when I try to login. Here's my code for the getLoginUrl()
:
<?php
$fb = new Facebook\Facebook([
'app_id' => 'MYAPPID',
'app_secret' => 'MYAPPSECRET',
'default_graph_version' => 'v2.5',
]);
$redirectURI = 'http://example.com/login-callback.php';
$encodedRedirectURI = urlencode($redirectURI);
$helper = $fb->getRedirectLoginHelper();
$loginUrl = $helper->getLoginUrl(
array(
'scope' => 'ads_management,read_insights',
'redirect_uri' => $encodedRedirectURI
)
);
echo '<a href="' . $loginUrl . '">Log in with Facebook!</a>';
?>
Why is this error happening?