简体   繁体   中英

how to remove asking for permissions from facebook when posting with javascript

Hi I am making webapp which can post a photo to a user timeline. How can i remove the asking for permissions when doing this because i dont want people to be asked to give permissions to the app to view they profile and friends. At least can i limit the options. This is my code:

window.fbAsyncInit = function() {
            FB.init({
               appId      : '544097612372144',
               status     : true,
               xfbml      : true
            });
            var accessToken;
            $(document).on("click", ".facebook", function() {
               FB.login(function(){
                  FB.getLoginStatus(function (response) {
                     if (response.authResponse) {
                        accessToken = response.authResponse.accessToken;
                        console.log(response.authResponse.accessToken);
                     } else {
                        // do something...maybe show a login prompt
                     }
                     PostImageToFacebook(accessToken);
                  });
               }, {scope: 'publish_actions'});
            });
         };

What you are asking for is, most probably, impossible. Facebook implements the OAuth2 protocol , so as to give you access to its users' data through its API. Your users have to authenticate with Facebook and grant specific permissions to your application (whichever and how many they like); thus Facebook protects their privacy.

The thing is that this has to happen just one single time actually; the first time the users authenticate with your app. After authenticating and granting specific permissions to your applications, you will receive an OAuth2 access token , which you have to store in your database (and never expose to the public, since it is really sensible data) and with which you will authenticate your requests to Facebook.

Facebook has released an Official PHP SDK and refers some third-party SDKs as well, which can help you perform authenticated requests to the Facebook API, with a couple of lines of code.

I hope this helped you.

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