在我的应用程序中,我有我的用户使用FB连接并授予我的应用程序权限。验证用户使用FB.getLoginStatus授予请求的权限
当他们点击连接按钮时,FB弹出窗口被显示,他们得到 “用facebook登录”,然后他们需要对publish_stream,manage_pages和email的最高权限。
我的代码存在的问题是,如果他们删除其中一个权限(如manage_pages),checkLoginStatus仍然允许用户继续。
那么如何验证用户已授予请求的权限?
<div id="fb-root"></div>
<script src="//connect.facebook.net/en_US/all.js"></script>
<script type="text/javascript">
FB.init({
appId: '<?=FB_APP_ID?>',
status: true,
cookie: true
});
FB.getLoginStatus(checkLoginStatus);
function authUser() {
FB.login(checkLoginStatus, {scope:'publish_stream, manage_pages, email'});
}
function checkLoginStatus(response) {
if(response && response.status == 'connected') {
$('#connbut').hide();
FB.api('/me', function(user) {
if (user) {
$('#fbuser-name').text(user.name);
$('#fbuserpict').attr('src', 'https://graph.facebook.com/' + user.id + '/picture');
$('#fbname').val(user.name);
$('#fbpict').val('https://graph.facebook.com/' + user.id + '/picture');
}
});
} else {
// Display the login button
$('#connbut').show();
}
}
</script>