Reputation: 21
I use this code to take information about people friends with Facebook :
require 'facebook-php-sdk-master/src/facebook.php';
$app_id = 'xxxxxxx';
$app_secret = 'xxxxxxxx';
$facebook = new Facebook(array(
'appId' => $app_id,
'secret' => $app_secret,
));
$user = $facebook->getUser();
if ($user) {
try {
$user_profile = $facebook->api('me/friends');
print_r($user_profile);
} catch (FacebookApiException $e) {
error_log($e);
$user = null;
}
} else {
$params = array(
'scope' => 'user_birthday',
);
$loginUrl = $facebook->getLoginUrl($params);
echo("<script> top.location.href='" . $loginUrl . "'</script>");
}
?>
But now, a lot of time, when i try to load this , i see that in the url the param "code" start to change a lot of time and the page don't load. What kind of problem is that?
Upvotes: 0
Views: 103
Reputation: 49044
$user
is false in your code for some reason (always). May be the facebook user didn't accept your app. $facebook->getLoginUrl($params);
redirects to the request uri, with $user
false the request uri redirects to $loginUrl
. This cause an endless loop.
Upvotes: 1