【问题标题】:Direct access after authentication insteed iframe access身份验证后直接访问而不是 iframe 访问
【发布时间】:2012-03-11 14:32:31
【问题描述】:

当用户授权我的应用程序时,他会被重定向到我的网站,而不是我的应用程序在 iframe 中的 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>");
}
?>

【问题讨论】:

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


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-05-26
      • 2014-03-24
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多