2009-12-11 164 views
1

我想在我的網站上有一個連接按鈕。一旦用戶點擊了Facebook登錄按鈕,彈出窗口會要求用戶輸入驗證詳細信息,父窗口將重定向或刷新頁面,並且登錄按鈕成爲註銷按鈕。Facebook連接登錄問題

我的問題是,當用戶點擊彈出連接按鈕時,彈出頁面將重定向到我的畫布頁面,而不是關閉彈出窗口。

+0

請提供一些代碼,所以我們可以檢查發生了什麼。另外,你是否爲你的fb:login-button指定了一個'onlogin'屬性? – jlb 2009-12-11 15:04:35

回答

2

很多人都發布過這個問題,如果你已經做了一切正確的話,原因是xd_receiver文件沒有被fb讀取。

您需要確保您的fb連接按鈕的位置,指定了該頁面底部某處xd_receiver.html文件的正確路徑。類似下面:

<script type="text/javascript"> 
    FB.init("your api key here", "xd_receiver.htm"); 
</script> 

它甚至更好,更容易把xd_receiver文件在您的網站的根文件夾,並與全域網址像這樣指定它:

<script type="text/javascript"> 
    FB.init("your api key here", "http://www.yoursite.com/xd_receiver.htm"); 
</script> 
+0

嘿Sarfraz,你有這些問題的人都問過這個問題的清單嗎?我登錄後得到'this._opts.channelUrl爲空'javascript錯誤。該網站沒有重定向,但是如果手動刷新,我發現我已登錄。 – sholsapp 2010-08-19 06:34:34

0

這裏的Facebook的樣品連接,登錄和註銷,工作得非常好, 另外,還要確保你加下您的應用程序設置你的網站URL - >網站 - >網站網址:Your Site URL

<!DOCTYPE html> 
    <html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml"> 
     <head> 
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> 
      <title>Facebook Connect Sample</title> 
     </head> 
     <body> 
      <div id="fb-root"></div> 
      <script> 
      window.fbAsyncInit = function() { 
       FB.init({ 
        appId : 'YOUR APP ID', 
        status : true, // check login status 
        cookie : true, // enable cookies to allow the server to access the session 
        xfbml : true // parse XFBML 
       }); 

      /* All the events registered */ 
      FB.Event.subscribe('auth.login', function(response) { 
       // do something on login 
       login(); 
      }); 
      FB.Event.subscribe('auth.logout', function(response) { 
       // do something on logout 
       logout(); 
      }); 

      FB.getLoginStatus(function(response) { 
       if (response.session) { 
        // logged in and connected user, someone you know 
        login(); 
       } 
      }); 
     }; 

     /* Loading the JS SDK Asynchronously - Refer: https://developers.facebook.com/docs/reference/javascript/ */ 
     (function() { 
     var e = document.createElement('script'); 
     e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js'; 
     e.async = true; 
     document.getElementById('fb-root').appendChild(e); 
     }()); 

    function login(){ 
     window.location = "http://google.com"; // Redirect to Another Page. 

     /* Show User's Name 
     FB.api('/me', function(response) { 
      document.getElementById('login').style.display = "block"; 
      document.getElementById('login').innerHTML = response.name + " succsessfully logged in!"; 
     }); 
     */ 
    } 
    function logout(){ 
     document.getElementById('login').style.display = "none"; 
    } 
    </script> 
    <p><fb:login-button autologoutlink="true"></fb:login-button></p> 
     <div id="login" style ="display:none"></div> 
</body> 
</html>