下面的代码适用于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