How do I ask for a facebook permission?
Chrome blocks the pop up and throws a lot of warning when using FB.login
function askPermission() {
FB.login( function(response) {
if(response.authResponse) {
// Do what I want to do
}
}, {scope:'publish_stream'});
}
So instead, I tried this from How to set permission dialog for post message on wall:
function askPermission(appid, redirect_uri, response_type, scope, callback) {
// Redirect the user back after authorization
var path = 'https://www.facebook.com/dialog/oauth?';
var queryParams = ['client_id='+appid, 'redirect_uri='+encodeURI(redirect_uri), 'response_type='+response_type, 'scope='+scope];
var query = queryParams.join('&');
var url = path + query;
top.location.href = url;
}
but it didn’t work as well. I received an error message, something like
“Occurred an error in YourApp. Try again later.”
EDIT:
Chrome still throwed a lot of ‘Unsafe JavaScript attempt to access frame with URL’ even when i tried :
<input type="button" value="Convidar amigos" class="verde" onclick="FB.login(function(response){ if(response.authResponse){post();} }, {scope:'email,publish_stream'});"/>
You should only call
FB.loginon user interaction (click, submit, etc) or it will be blocked in most browsers. The errors you see are because JS-SDK can’t interact with blocked window.