douchixu3686 2012-10-28 07:34
浏览 88
已采纳

Facebook授权(oauth)将应用程序重定向到iFrame(在php中)

My facebook app is getting redirected out of the iFrame on authorization. I have used the facebook.php and base_facebook.php from gitHub without any change and have pretty much followed example.php. What could I be missing?:

$facebook = new Facebook(array(
    'appId'  => $configParam['appId'],
    'secret' => $configParam['secret']
));
$appId=$configParam['appId'];
$user = $facebook->getUser();
if ($user==null) {
    $loginUrl = $facebook->getLoginUrl(array(
            'scope' => $perm
                ));     
    $loginUrl = $facebook->getLoginUrl();
    echo "<script type='text/javascript'>top.location.href = '$loginUrl';</script>";
}

The loginUrl is constructed in base_facebook.php as:

$this->establishCSRFTokenState();
$currentUrl = $this->getCurrentUrl();
return $this->getUrl(
'www',
'dialog/oauth',
array_merge(array(
        'client_id' => $this->getAppId(),
        'redirect_uri' => $currentUrl, // possibly overwritten
        'state' => $this->state),
      $params));
  • 写回答

1条回答 默认 最新

  • doumeng1897 2012-10-29 01:01
    关注

    It is a combination of things you have take care of to solve these two problems: 1. facebook authorization redirecting app out of iFrame (as mentioned by ifaour) 2. app going into a loop 3. app going into a loop only in IE

    For (1), everything must be consistently https (or http). I did have my secure canvas url as https but had left my canvas url as http (I thought this was fine). Apparently, both should be https

    For (2), the OOB facebook-php integration code at GitHub uses Current URL as redirect_uri. You have to change that to apps.facebook.com/namespace- note that that this has to be done at two places in base_facebook.php - getLoginUrl and getAccessTokenFromCode

    For (3) look at Why my FB app loops forever in IE?

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 宇视监控服务器无法登录
  • ¥15 PADS Logic 原理图
  • ¥15 PADS Logic 图标
  • ¥15 电脑和power bi环境都是英文如何将日期层次结构转换成英文
  • ¥15 DruidDataSource一直closing
  • ¥20 气象站点数据求取中~
  • ¥15 如何获取APP内弹出的网址链接
  • ¥15 wifi 图标不见了 不知道怎么办 上不了网 变成小地球了
  • ¥50 STM32单片机传感器读取错误
  • ¥50 power BI 从Mysql服务器导入数据,但连接进去后显示表无数据