facebook oauth, no picture with basic permissions

后端 未结 5 1465
耶瑟儿~
耶瑟儿~ 2020-12-25 14:33

I\'m using oauth to log facebook users in to my app. I\'m testing with my FB account and with the basic permissions scope. Facebook docs say that I should be able to get \

5条回答
  •  执笔经年
    2020-12-25 15:12

    Actually you don't need to allow public access to get the profile picture since you can get the USER_ID. Though the USER_ID you can navigate to the profile picture easily.

    function checkLoginState() {
        FB.getLoginStatus(function(response) {
            statusChangeCallback(response);
            console.log('Welcome!  Fetching your information.... ');
            var url = '/me?fields=id,name';
            FB.api(url, function(response) {
                 var linkpp = 'https://graph.facebook.com/' + response.id + '/picture?type=large';
                 document.getElementById("id_of_link_tag").href = linkpp;
            });
        });
    }
    

    You can change the type in variable linkpp to type=small which returns a low resolution image.

    var linkpp = 'https://graph.facebook.com/' + response.id + '/picture?type=small';
    

提交回复
热议问题