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

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?

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

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料