0

我使用OAuth對話框獲取應用程序啓動時的用戶電子郵件...所以在點擊應用程序url (https://apps.facebook.com/redirecttestapp/)而不是允許窗口時,我看到了登錄到應用程序窗口以及如果我點擊登錄,然後我看到允許窗口..如何擺脫登錄到應用程序窗口?這裏是代碼:Oauth權限請求窗口未顯示使用Facebook javascript

<script> 

    var href = "https://apps.facebook.com/redirecttestapp/"; 
     var appliId = "233664670032230"; 
     window.fbAsyncInit = function() { 
     FB.init({ 
      appId  : '********', // App ID 
      channelURL : '//apps.facebook.com/redirecttestapp/', // Channel File 
      status  : true, // check login status 
      cookie  : true, // enable cookies to allow the server to access the session 
      oauth  : true, // enable OAuth 2.0 
      xfbml  : true // parse XFBML 
     }); 

     // Additional initialization code here 

       FB.getLoginStatus(function(response) { 
       if (response.status === 'connected') { 
       // the user is logged in and connected to your 
       // app, and response.authResponse supplies 
       // the user’s ID, a valid access token, a signed 
       // request, and the time the access token 
       // and signed request each expire 
       alert("the user is logged in and connected to your app"); 
       var uid = response.authResponse.userID; 
       var accessToken = response.authResponse.accessToken; 
       } else if (response.status === 'not_authorized') { 
       // the user is logged in to Facebook, 
       //but not connected to the app 
       alert("the user is logged in to Facebook,but not connected to the app"); 
       } else { 
       // the user isn't even logged in to Facebook. 

       // alert("the user isn't even logged in to Facebook."); 
       top.location.href = "https://www.facebook.com/dialog/oauth?client_id=233664670032230&redirect_uri="+href+'&display=page'; 
       } 
      }); 
     }; 

     // Load the SDK Asynchronously 
     (function(d){ 
     var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;} 
     js = d.createElement('script'); js.id = id; js.async = true; 
     js.src = "//connect.facebook.net/en_US/all.js"; 
     d.getElementsByTagName('head')[0].appendChild(js); 
     }(document)); 

    </script> 

回答

相關問題