---------------------------------------------------------------------------------------
Correct way to use to get permission only if user have not grantd a parmission...
Code is:
var is_initialized = false;
// Ensure Facebook app is initialized and call callback afterward
function ensure_init(callback) {
if(window.is_initialized) {
callback();
} else {
FB_RequireFeatures(["XFBML"], function() {
//FB.FBDebug.logLevel = 4;
//FB.FBDebug.isEnabled = true;
FB.Facebook.init(
window.is_initialized = true;
callback();
});
}
}
function facebook_prompt_permission(permission, callbackFunc) {
ensure_init(function() {
//check is user already granted for this permission or not
FB.Facebook.apiClient.users_hasAppPermission(permission,
function(result) {
// prompt offline permission
if (result == 0) {
// render the permission dialog
FB.Connect.showPermissionDialog(permission, callbackFunc);
} else {
// permission already granted.
callbackFunc(true);
}
});
});
}
function statusSubmit() {
// this checks current status of permission and if not granted it will display an ajax box for user to give permission.
facebook_prompt_permission('email', function(accepted) {
if(accepted) {
// do something here. I send the status that the user has written to FB via an AJAX request.
alert("hiii");
var result=FB.Facebook.apiClient.users_getInfo(UID,'proxied_email',function (result,ex) { alert("here lets try "+result[0]['proxied_email']);});
}
else {
alert("bii");
}
});
}
----------------------------------------------------------
call
statusSubmit();