2011-08-27 158 views
0

我有以下代碼:Facebook在登錄後(Facebook身份驗證)不會在主頁上重定向?

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"> 
<html lang="en-US" xml:lang="en-US"> 
<head> 
    <title>Login Page</title> 
</head> 
<body> 
<div id="fb-root"></div> 
    <script type="text/javascript" src="http://connect.facebook.net/en_US/all.js"></script> 
    <script type="text/javascript"> 
    FB.init({ 
       appId:'MY_APP_ID', cookie:true, 
       status:true, xfbml:true 
      }); 
    </script> 
<div id="login-box"> 
    <fb:login-button perms="email,offline_access" redirect_uri="http://mydomain.com:8000/home/"> 
     Facebook 
    </fb:login-button> 
</div> 
</body> 
</html> 

它要求用戶允許的特權,但它成功後,允許用戶應用程序,並保持在同一頁上不重定向到redirect_uri頁面。

這是一個django應用程序的一部分。

+0

您是否嘗試過編碼'redirect_uri'網址是什麼? ('http%3A%2F%2Fmydomain.com%3A8000%2Fhome%2F') – steveax

+0

是的..這是@moguzalp –

回答

1

一種選擇是使用的登錄參數來重定向:

<fb:login-button perms="email,offline_access" on-login="window.location = 'http://www.example.com';">Facebook</fb:login-button> 
+0

你能指出我的代碼中的問題嗎? –

+0

在你的情況下,我將如何獲得訪問代碼。在你的情況下,Facebook不會傳遞access_code。 –

0

也許嘗試加入

<script type="text/javascript" src="http://connect.facebook.net/en_US/all.js"></script> 
    <script type="text/javascript"> 
     window.fbAsyncInit = function() { 
     FB.init({ 
      appId: 'appid', 
      cookie: true, 
      xfbml: true, 
      oauth: true 
     }); 

     // whenever the user logs in, we refresh the page 
     FB.Event.subscribe('auth.login', function(response) { 
      window.location="your redirect"; 
     }); 
     }; 
    </script> 
+0

我的代碼有什麼問題? –

+0

你將如何獲得access_code,因爲在你的情況下,facebook不會返回任何access_code! –

相關問題