Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to request permissions for facebook app with JavaScript

How can I check the current user login status and ask for permissions for my app? This recently changed and now my app is not working anymore. Thanks for your help!

like image 482
Loop Dev Avatar asked Jan 20 '12 14:01

Loop Dev


1 Answers

I always use this setup to handle login status and permissions:

function getPerms() {
    FB.login(function(response) {
        if (response.authResponse) {
            //user has granted permissions
        }
    }, {scope:"email, ..."});
}

function getStatus() {
    FB.getLoginStatus(function(response) {
        if (response.status === "connected") {
            //user has granted permissions
        } else {
            getPerms();
        }
    });
}

You still have to include the all.js and call FB.init(...)

like image 104
user7171 Avatar answered Oct 12 '22 05:10

user7171