2016-10-07 1 views
0

私は自分のウェブサイトにfacebookでログインしてもらいたいが、このエラーが表示されます。解決方法「この人はFacebookにログインしていますが、あなたのアプリはありません」javascript sdk

<script> 
    // This is called with the results from from FB.getLoginStatus(). 
    function statusChangeCallback(response) { 
    console.log('statusChangeCallback'); 
    // for FB.getLoginStatus(). 
    if (response.status === 'connected') { 
     // Logged into your app and Facebook. 
     // alert('login fb'); 
     document.getElementById('login').style.display = 'none'; 
     document.getElementById('startbtn').style.display = 'block'; 

     testAPI(); 
    } else if (response.status === 'not_authorized') { 
     // The person is logged into Facebook, but not your app. 
     alert('not authorized'); 

    } else { 
     // The person is not logged into Facebook, so we're not sure if 
     alert('not login fb'); 
     document.getElementById('login').style.display = 'block'; 
     document.getElementById('startbtn').style.display = 'none'; 
    } 
    } 

    function checkLoginState() { 
    FB.getLoginStatus(function(response) { 
     statusChangeCallback(response); 
    }); 
    } 

    window.fbAsyncInit = function() { 
    FB.init({ 
    appId  : 'my app id', 
    oauth : true, 
    cookie  : true, // enable cookies to allow the server to access 
         // the session 
    xfbml  : true, // parse social plugins on this page 
    version : 'v2.5' // use graph api version 2.5 
    }); 

</script> 

これは、MYCOMPUTERおよびその他のcomputer.Butにコンピュータ 表示する警告(許可されていない)のいずれかを仕事とログインできません。 この問題をどうやって解決できますか?

答えて

0

ステータスがnot_authorizedの場合、facebookのログインビューを呼び出すことができます。これを試してください:

if (response.status === 'not_authorized') { 
     // The person is logged into Facebook, but not your app. 
     console.log('Please log into this app.'); 
     fbLogin(); 
    } 

    function fbLogin(){ 
     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.'); 
     } 
    }); 

    } 
+0

私はまだ新しいエラーに直面しています。 Firefoxがこのサイトの新しいポップアップウィンドウを開くのを防ぎました。 –

関連する問題