1

When the user authorize my app, he is redirected to my site and not to facebook with my app in the iframe. Is there a way to stay in facebook ? My code :

require './src/facebook.php';

$config = array();
$config['appId'] = 'XXXXX';
$config['secret'] = 'XXXXX';
$config['fileUpload'] = false; // optional

$facebook = new Facebook($config);

$user = $facebook->getUser();

if ($user) {
  try {
    // Proceed knowing you have a logged in user who's authenticated.
    $user_profile = $facebook->api('/me');
  } catch (FacebookApiException $e) {
    error_log($e);
    $user = null;
  }
}

// Login or logout url will be needed depending on current user state.
if ($user) {
    echo "blah";
} else {
  $params = array(
      'scope' => 'read_stream, friends_likes',
      'redirect_uri' => 'https://xxxxx'
    );

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

1 Answer 1

0

Try putting your app's url (http://apps.facebook.com/your_app_namespace) in the redirect_uri param. This should fix the issue you are facing.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.