Gabriel Santos
Gabriel Santos

Reputation: 4974

Facebook API redirect to wrong place

$facebook = new Facebook($configs);
$uid = $facebook->getUser();

if($uid) {
    // Do stuffs
} else {
    $loginUrl = $facebook->getLoginUrl();

    echo('<script> top.location.href = "' . $loginUrl . '";</script>');
}
?>

All work perfectly, but, if user are not logged, the script redirect to Facebook which ask login. When login, the script redirect to my application external url http://mywebsite.com/facebook-app and not my apps.facebook.com/myappid.

Upvotes: 2

Views: 677

Answers (2)

Gunnar Karlsson
Gunnar Karlsson

Reputation: 28480

Check that the URLs on the apps settings page on Facebook Developer are correct. If your app is of the 'App on Facebook' type, check that

Canvas URL
Secure Canvas URL

are correct.

If it's a 'Mobile Web' app, check

Mobile Web URL

and so on depending on the type of app.

Upvotes: 1

elliottbolzan
elliottbolzan

Reputation: 1077

Try adding this to your $loginUrl:

$loginUrl = $facebook->getLoginUrl(array(
    'next'=>'http://apps.facebook/myappid'
));

Haven't encountered this problem in particular, but this might be of use !

Upvotes: 1

Related Questions