не удалось войти на Facebook с использованием javascript sdk - PullRequest
0 голосов
/ 06 марта 2019

Я использую логин на Facebook ... но недавно у меня возникла ошибка при получении данных для входа / подписки

это мой код

  <script>
    // This is called with the results from from FB.getLoginStatus().
    function statusChangeCallback(response) {
        console.log('statusChangeCallback');
        console.log(response);
        if (response.status === 'connected') {
            // Logged into your app and Facebook.
            testAPI();
        } else if (response.status === 'not_authorized') {
            fbLogin();
            // The person is not logged into your app or we are unable to tell.
            document.getElementById('status').innerHTML = 'Please log ' +'into this app.';
        }
        else {
            // The person is not logged into your app or we are unable to tell.
            document.getElementById('status').innerHTML = 'Please log ' +'into this app.';
        }
    }
    function checkLoginState() {
        FB.getLoginStatus(function (response) {
            statusChangeCallback(response);
        });
    }
    function fbLogin() {
        debugger;
        FB.login(function (response) {
            //if (response.authResponse) {
                console.log('Welcome!  Fetching your information.... ');
                FB.api('/me/?fields=picture,name,email', function (response) {
                    console.log(response);
                    console.log('Successful login for: ' + response.name);
                    document.getElementById('status').innerHTML =
                      'Thanks for logging in, ' + response.name + '!';
                });
            //} else {
            //    console.log('User cancelled login or did not fully authorize.');
            //}
        }, { auth_type: 'reauthenticate', auth_nonce: '{random-nonce}' });
    }
    window.fbAsyncInit = function () {
        FB.init({
            appId: '393788184007786',
            cookie: true,  // enable cookies to allow the server to access 
            // the session
            xfbml: true,  // parse social plugins on this page
            version: 'v3.2' // The Graph API version to use for the call
        });
    };
    // Load the SDK asynchronously
    (function (d, s, id) {
        var js, fjs = d.getElementsByTagName(s)[0];
        if (d.getElementById(id)) return;
        js = d.createElement(s); js.id = id;
        js.src = "https://connect.facebook.net/en_US/sdk.js";
        fjs.parentNode.insertBefore(js, fjs);
    }(document, 'script', 'facebook-jssdk'));

    // Here we run a very simple test of the Graph API after login is
    // successful.  See statusChangeCallback() for when this call is made.
    function testAPI() {
        console.log('Welcome!  Fetching your information.... ');
        FB.api('/me', { fields: 'name,email' }, function (response) {
            var info = response.id + '#' + response.name + '#' + response.email;
            console.log('Successful login for: ' + info);         
        });
    }
</script>

и эта кнопка включена в html для входа

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

и ответ от getLoginState ():

{ authResponse: undefined, status: "not_authorized" }

и отображается эта ошибка введите описание изображения здесь

Я получаю сообщение в приложении Facebook, в котором говорится: «Мы ограничили это приложение за нарушение Политики платформы Facebook»

есть предложения по решению этой проблемы? !!

1 Ответ

0 голосов
/ 06 марта 2019

Скобки - просто заполнители, вы должны удалить их:

FB.init({
    appId: '393788184007786',
    cookie: true, 
    xfbml: true,  
    version: 'v3.2' 
});
...