2011-08-29 209 views
0

下面的代码适用于Linux和Windows上最新版本的Chrome,Linux和Windows中最新版本的Firefox以及Windows上除IE9以外的所有IE版本。浏览器不兼容问题

不幸的是,与IE9在Windows和Chrome和Firefox的最新版本预计在MacOS

它不工作我做了几个测试,我发现,从Facebook应用程序的画布页面重定向当错误发生到使用IFrame显示第一个应用程序的另一个Facebook画布应用程序。发生重定向时$user在上述MacOS上的浏览器和Windows上的IE中为空,但它不为空,并且按照第一段中提到的每个浏览器的预期工作。

有什么建议吗?

<?php  
$user   = null; //facebook user uid 
try{ 
    include_once "src/facebook.php"; 
    include_once "src/fb_logger.php"; 
} 
catch(Exception $o){ 
    echo '<pre>'; 
    print_r($o); 
    echo '</pre>'; 
} 
// Create our Application instance. 
$facebook = new Facebook(array(
    'appId' => $fbconfig['appid'], 
    'secret' => $fbconfig['secret'], 
    'cookie' => true, 
)); 

//Facebook Authentication part 
$user  = $facebook->getUser(); 

// We may or may not have this data based 
// on whether the user is logged in. 
// If we have a $user id here, it means we know 
// the user is logged into 
// Facebook, but we dont know if the access token is valid. An access 
// token is invalid if the user logged out of Facebook. 

$loginUrl = $facebook->getLoginUrl(
     array(
      'scope'   => 'user_status,publish_stream,user_photos' 
     ) 
); 

if ($user) { 
    try { 
    // Proceed knowing you have a logged in user who's authenticated. 
    $user_profile = $facebook->api('/me'); 

      if(isset($_GET['iframe']) || isset($_GET['code']))) { 
    } 
    else { 
    echo "<script type='text/javascript'> 
     if(window.location.href.toLowerCase().indexOf('iframe') != -1 || window.location.href.toLowerCase().indexOf('oauth') != -1 || window.location.href.toLowerCase().indexOf('code') != -1) { 
     } 
     else 
          //opening new application with iframe to show the previous one 
      window.open('link to the iframe pointing to the this application', '_parent', ''); 
     </script>"; 
     exit; 
    } 
    } catch (FacebookApiException $e) { 
    //you should use error_log($e); instead of printing the info on browser 
    //d($e); // d is a debug function defined at the end of this file 
    $user = null; 
    } 
} 

if (!$user) { 
    echo "<script type='text/javascript'>top.location.href = '$loginUrl';</script>"; 
    exit; 
} 
?> 
+1

可能与“cookie”=> true,乍一看有关。 cookies是否在浏览器中正确设置了?浏览器报告他们拥有哪些cookies? – hakre

+0

我现在无法在Mac上访问Chrome或Firefox,但我在Windows上使用IE9再次测试了应用程序。在测试之前,我去了'Internet Options' - 'Privacy' - 我在那里设置了选项'Accept all cookies'。它的工作。你能提出任何解决方法吗? – glarkou

+0

我并不是想检查选项,而是对实际的原始cookie标题以及浏览器数据结构中的那些标题的解释感兴趣。没有关于IE9的想法处理它们以及在哪里找到它们。我对IE的支持已经以IE 6结束了,而IE 6很好地完成了这项工作。 – hakre

回答

1

我想我找到了解决办法

我说:在我的代码

//required for IE in iframe FB environments if sessions are to work. 
header('P3P:CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"'); 

和它现在的工作。

+0

我总是忘记这一点。该死的P3P头。耶为堆栈溢出。 – weotch

+0

顺便说一句,我已经得到了一个缩减集,我从这里偷了工作:http://tempe.st/2010/11/cookies-in-iframes-how-bashing-my-head-on-the-table订做了他们,工作在互联网资源管理器/。只是“NOI DSP LAW NID” – weotch