Hi,
I'm looking at ways to add permissions that are needed as and when my site grows. e.g. if i develop a service to manage pages, only when a user enables the service will they then see a popup asking for the relavant permissions. I have found the fb code and would like to know how to implement it via the jfbconnect api. Below is the code i found:
facebook permissions
Login
Check Permissions
Remove Permissions
FB.init({
appId : 'YOUR_APP_ID',
status : true, // check login status
cookie : true, // enable cookies
xfbml : true, // parse XFBML
oauth : true // enable OAuth 2.0
});
// Permissions that are needed for the app
var permsNeeded = ;
// Function that checks needed user permissions
var checkPermissions = function() {
FB.api('/me/permissions', function(response) {
var permsArray = response.data[0];
var permsToPrompt = [];
for (var i in permsNeeded) {
if (permsArray[permsNeeded
] == null) {
permsToPrompt.push(permsNeeded);
}
}
if (permsToPrompt.length > 0) {
alert('Need to re-prompt user for permissions: ' +
permsToPrompt.join(','));
promptForPerms(permsToPrompt);
} else {
alert('No need to prompt for any permissions');
}
});
};
// Re-prompt user for missing permissions
var promptForPerms = function(perms) {
FB.login(function(response) {
console.log(response);
}, {scope: perms.join(',')});
};
var removePermissions = function(perms) {
FB.api(
{
method: 'auth.revokeExtendedPermission',
perm: perms.join(',')
},
function(response) {
console.log(response);
}
);
};
document.getElementById("login").onclick = function() {
FB.login(function(response) {
console.log(response);
}, {scope: permsNeeded.join(',')});
};
document.getElementById('checkPerms').onclick = function() {
checkPermissions();
};
document.getElementById('removePerms').onclick = function() {
removePermissions();
};
I did try to add some of the code but i broke the login part of the site. I'm assuming that jfbconnect declares it's own global variable(wrapper) to then interact with the facebook library. So it should need a few changes of the above code to have it working with jfbconnect.
many Thanks in advanced