下面的代碼適用於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;
}
?>
可能與「cookie」=> true,乍一看有關。 cookies是否在瀏覽器中正確設置了?瀏覽器報告他們擁有哪些cookies? – hakre
我現在無法在Mac上訪問Chrome或Firefox,但我在Windows上使用IE9再次測試了應用程序。在測試之前,我去了'Internet Options' - 'Privacy' - 我在那裏設置了選項'Accept all cookies'。它的工作。你能提出任何解決方法嗎? – glarkou
我並不是想檢查選項,而是對實際的原始cookie標題以及瀏覽器數據結構中的那些標題的解釋感興趣。沒有關於IE9的想法處理它們以及在哪裏找到它們。我對IE的支持已經以IE 6結束了,而IE 6很好地完成了這項工作。 – hakre