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?

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

报告相同问题?

悬赏问题

  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥30 BC260Y用MQTT向阿里云发布主题消息一直错误
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)