这是一个可选权限,但我无法在我的画布应用中跳过它,当我点击此“权限”上的“跳过”时,我的页面会被重定向,一次又一次地请求此权限。任何人都知道为什么会这样?
非常感谢! :)
<!-- 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>
答案 0 :(得分:3)
如果没有看到您的身份验证码,很难确定,但我确信您有
FB.login()
,类似两者都会导致循环
答案 1 :(得分:0)
oauth_url += '&scope=email'
而不是您拥有的内容?或者,您可以尝试构建没有范围的oauth URL,并查看应用程序要求的权限。如果它要求特定权限,请检查登录功能并查看是否已设置某些权限。如果我没记错的话,应该是在facebook.php文件中。