How to request additional permissions during an FBJS Ajax call

Here’s something we learned with FANBLDR, our Facebook Page Maker. If you do an Ajax call in FBML+FBJS, you can use the requireLogin=1 attribute to request permissions. These will then be sent to the
receiving script via POST. However, what if you need extra permissions? Try this:

Facebook.showPermissionDialog('publish_stream', function() {
var ajax = new Ajax();
ajax.requireLogin = 1;
ajax.responseType = Ajax.RAW;
ajax.onerror = function(data) {
permissionDialog = new Dialog().showMessage(’Error posting’, ‘Unknown error. Try again later.’, ‘OK’);
}
ajax.ondone = function(data) {
if (data == ‘ok’) {
// hide the form and tell ‘em thanks
document.getElementById(’tipform’).setStyle(’display’,'none’);
document.getElementById(’submitted’).setStyle(’display’,'block’);
} else {
permissionDialog = new Dialog().showMessage(’Error posting’, data, ‘OK’);
}
return false;
};
ajax.post(u, q);
return false;
});
return false;

Let us know if it works out, and check out our new blog too: FANblog.

One Response to “How to request additional permissions during an FBJS Ajax call”

  1. STR8BLOGGIN » Blog Archive » How to request additional permissions … | Programming Blog Imagik.org Says:

    sent to the receiving script via POST Read more from the original source: STR8BLOGGIN » Blog Archive » Ho […]

Leave a Reply