2011-09-06 18 views
0

我正在構建Facebook IFrame應用程序,我請求用戶允許該應用程序的權限。當用戶第一次登錄我的應用程序時,IFrame應用程序將彈出一個窗口來請求用戶允許權限。如何在top.location上創建Facebook FB.login()對話框

我的問題是:我不希望這個權限窗口彈出,這個彈出窗口可以像「top.location.href」,只是在我的應用程序頁面的頂部。

我的代碼是

  window.fbAsyncInit = function() { 
      FB.init({appId: '', 
        status: true, 
        cookie: true, 
        xfbml: true, 
        oauth : true //enables OAuth 2.0 
        }); 


      FB.getLoginStatus(function(response) { 
       if (response.authResponse) { 

       } else { 
        FB.login(); 

       } 
      }); 

     }; 
     (function() { 
      var e = document.createElement('script'); 
      e.type = 'text/javascript'; 
      e.src = document.location.protocol + 
       '//connect.facebook.net/en_US/all.js'; 
      e.async = true; 
      document.getElementById('fb-root').appendChild(e); 
     }()); 

     FB.login(function(response) { 
      if (response.authResponse) { 
      console.log('Welcome! Fetching your information.... '); 
      FB.api('/me', function(response) { 
       console.log('Good to see you, ' + response.name + '.'); 
       FB.logout(function(response) { 
       console.log('Logged out.'); 
       }); 
      }); 
      } else { 
      console.log('User cancelled login or did not fully authorize.'); 
      } 
     }, {scope: 'email'}); 

回答

0

這聽起來像你想你的整個頁面重定向到授權對話框,是嗎?

如果是這樣,你只需要你的頁面重定向到這一個:

https://www.facebook.com/dialog/oauth?client_id=YOUR_APP_ID&redirect_uri=YOUR_URL&scope=email 

...其中YOUR_URL是要帶他們到屏幕的權限後的頁面。