简体   繁体   中英

JavaScript - Adding permissions on Facebook

I'm reading this tutorial

Until now, I used the sample code in the link above under "Quick start" section. And basically, what I got is a log in button, and when I click on it, a window appears saying that the application is going to use my public profile and email.

I want to expand the permissions, for example getting an access to the likes/friends etc...

According to the tutorial, I need to add the following code:

FB.login(function(response) {
   console.log(response);
 }, {scope: 'user_friends'});

However I don't understand where should I add it in the code that under the quick start section in the tutorial.

Where should I add it?

Thanks

In the tutorial they use component "fb:login-button" so that's where you specify scopes

<fb:login-button scope="public_profile,email,user_friends" onlogin="checkLoginState();">
</fb:login-button>

or you can use your own button with onclick event

function buttonOnClickHandler (){

    FB.login(function(response) {
      console.log(response);
        // specify desired scopes here
    }, {scope: 'public_profile,email,user_friends'});

}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM