验证后直接访问iframe访问

时间:2012-03-11 14:32:32

标签: php facebook-php-sdk facebook-authentication

当用户授权我的应用时,他被重定向到我的网站,而不是我的应用程序在iframe中的facebook。有没有办法留在Facebook? 我的代码:     

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 个答案:

答案 0 :(得分:0)

尝试将应用的网址(http://apps.facebook.com/your_app_namespace)放在redirect_uri参数中。这应该可以解决您面临的问题。