这是一个可选权限,但我无法在我的画布应用程序中跳过它,当我在此权限上单击“跳过”时,我的页面被重定向以一次又一次地询问此权限。任何人都知道为什么会这样?
非常感谢!:)
<!-- BEGINNING OF THE INDEX.PHP CODE -->
<?php
//SOLVES INFINITE LOOP ON IE
header('P3P: CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"');
// Enforce https on production
if (substr(AppInfo::getUrl(), 0, 8) != 'https://' && $_SERVER['REMOTE_ADDR'] != '127.0.0.1') {
header('Location: https://'. $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
exit();
}
$facebook = new Facebook(array( 'appId' => AppInfo::appID(), 'secret' => AppInfo::appSecret(), ));
$user_id = $facebook->getUser();
//Check if we have an user_id
if ($user_id!="0") {
try {
// Fetch the viewer's basic information
$basic = $facebook->api('/me');
} catch (FacebookApiException $e) {
// If the call fails we check if we still have a user. The user will be
// cleared if the error is because of an invalid accesstoken
if (!$facebook->getUser()) {
header('Location: '. AppInfo::getUrl($_SERVER['REQUEST_URI']));
exit();
}
}
} else {
// If the user is not connected to the application, redirect the user to authentication page
$login_url = $facebook->getLoginUrl(array('redirect_uri' => "https://apps.facebook.com/APP_NAME_SPACE/",'scope' => 'publish_stream,email','display' => 'page'));
?><html xmlns="https://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
</head>
<body>
<script type="text/javascript"> top.location.href='<?php echo $login_url; ?>'</script>
</body>
</html><?php
exit();
}
if(isset($basic)) {
$locale=idx($basic, 'locale');
$name=he(idx($basic, 'name'));
$email=he(idx($basic, 'email'));
} else {
// IF the user is not loggin on facebook, redirect the user to facebook login page
?>
<script type="text/javascript">
var oauth_url = 'https://www.facebook.com/dialog/oauth/';
oauth_url += '?client_id=APP_ID';
oauth_url += '&redirect_uri=' + encodeURIComponent('https://apps.facebook.com/APP_NAME_SPACE/');
oauth_url += '&scope=publish_stream,email'
window.top.location = oauth_url;
</script>
<?php
exit();
//ends execution if there's no login
}
?>
<html>
// APP HTML CODE
</html>