nicktendo
nicktendo

Reputation: 607

Request Facebook permissions without user leaving my website

Is it possible to get permission to access a Facebook user's User ID without having them leave your webpage? Is an iframe with the permission dialog the only true way to accomplish this?

Upvotes: 0

Views: 130

Answers (1)

Philip
Philip

Reputation: 5021

You can use the Javascript API to Extend Permissions. Lets say that you have already request the Email permission, If you pass a new permission to the login button, the User must approve the new perm also.

example Login Button:

<fb:login-button perms="friend_likes"></fb:login-button>

example FB.login()

function fbAuth() {
    FB.login(function(response) {
      if (response.authResponse) {
        alert('User fully authorize the app.');
      } else {
        alert('User canceled login or did not fully authorize the app.');
      }
    }, { scope: 'friend_likes' });
}

then you can call it with an onclick event or any other method you want:

<a href="#" onclick="return fbAuth();">Login</a>

Upvotes: 2

Related Questions