2012-07-02 82 views
6

突然我在嘗試通過Facebook登錄時在我的應用程序中發生了一件奇怪的事情。請求登錄詳細信息後,facebook連接彈出對話框將顯示空白屏幕。通常情況下,我希望看到窗口關閉,然後網站本身會繼續,但它似乎已經掛起。Facebook:FB上的黑屏登錄

我使用Javascript SDK on Localhost

這裏是我正在使用的代碼(直接在facebook上的文件複製):

window.fbAsyncInit = function() { 
    FB.init({ appId: fbAppId, 
     status: false, 
     cookie: true, 
     xfbml: true 
    }); 

}; 

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



$(document).ready(function() { 


    $("#fb_button_login").click(function() { 


     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 + '.'); 
       }); 
      } else { 
       console.log('User cancelled login or did not fully authorize.'); 
      } 
     }); 


    }); 

}); 

其他一些注意事項:

  • 這似乎是發生在所有瀏覽器上。
  • 我研究的所有其他職位,似乎無法找到適合我的解決方案
  • 有顯示控制檯了任何錯誤消息
  • 在開發我使用,我已經建立了獨立的FB應用程序ID專門爲我使用的指定端口本地主機
    • 我沒有沙盒模式使

(已經爲超過12個月的罰款)它似乎掛起的URL是here

謝謝你們。

+0

所以這開始發生在我身上,仍然「我研究了所有其他帖子,似乎無法找到適合我的解決方案」。你有沒有運氣? – joaoricardo000

回答

0

試試下面的代碼

<html> 
<body> 
<div id="fb-root"></div> 
<script type="text/javascript" src="http://connect.facebook.net/en_US/all.js"></script> 
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js" ></script> 
<script> 

FB.init({appId: fbAppId, status: true, cookie: true, xfbml: true}); 
$(document).ready(function() { 
    $("#fb_button_login").click(function() { 
     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 + '.'); 
       }); 
      } else { 
       console.log('User cancelled login or did not fully authorize.'); 
      } 
     }); 


    }); 
}); 

</script> 
<a href="javascript://" id="fb_button_login">Login</a> 
</body> 
</html>