2011-08-29 208 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