我的Facebook应用程序在Firefox中运行良好,但在点击链接时在IE中表现得很奇怪:它一直重定向,当点击iFrame中的链接时,它最终会重定向回index.php而不保留GET-Vars链接。它似乎总是重定向到authentification-URL。
这是我的画布页面的核心部分:index.php:
<?
require 'facebook-php-sdk-6c82b3f/src/facebook.php';
$facebook = new Facebook(array(
'appId' => 'XXX',
'secret' => 'YYY',
));
function get_facebook_cookie($app_id, $application_secret) {
$args = array();
parse_str(trim($_COOKIE['fbs_' . $app_id], '"'), $args);
ksort($args);
$payload = '';
foreach ($args as $key => $value) {
if ($key != 'sig') {
$payload .= $key . '=' . $value;
}
}
if (md5($payload . $application_secret) != $args['sig']) {
return null;
}
return $args;
}
$cookie = get_facebook_cookie('XXX', 'YYY');
// Get User ID
$user = $facebook->getUser();
if ($user) {
try {
// Proceed knowing you have a logged in user who's authenticated.
$user_profile = $facebook->api('/me');
} catch (FacebookApiException $e) {
error_log($e);
$user = null;
}
}
?>
<body onload="self.focus();document.tips.tip0A.focus()" scroll="no" style="overflow:hidden">
<div id="fb-root"></div>
<script type="text/javascript">
window.fbAsyncInit = function () {
FB.init({ appId: 'XXX', status: true, cookie: true, xfbml: true });
FB.Canvas.setSize({ height: 890 });
};
(function () {
var e = document.createElement('script');
e.type = 'text/javascript';
e.src = document.location.protocol +
'//connect.facebook.net/en_US/all.js';
e.async = true;
document.getElementById('fb-root').appendChild(e);
} ());
</script>
<?
if (!$user_profile[id]) {?>
<script>
var oauth_url = 'https://www.facebook.com/dialog/oauth/';
oauth_url += '?client_id=429812627032252';
oauth_url += '&redirect_uri=' + encodeURIComponent('https://apps.facebook.com/euro_challenge/');
oauth_url += '&scope=email,user_birthday'
window.top.location = oauth_url;
</script>
<?}?>
有什么想法吗?
答案 0 :(得分:0)
<?
header("p3p: CP=\"ALL DSP COR PSAa PSDa OUR NOR ONL UNI COM NAV\"");
?>
答案 1 :(得分:0)
Facebook建议使用伪造的P3P标题只是为了让IE开心。小心发出“真正的”P3P标题,因为它暗示您已制定了特定的隐私政策。它不仅仅是随机字符。
在此页http://developers.facebook.com/docs/samples/canvas/的开发者文档中,Facebook建议:
P3P: CP="HONK"