0
基本上,我是新來使用Facebook的API,我有試圖讓我的代碼工作,下面的代碼應該提供一個提示,如果用戶沒有登錄問題,但我不知道它有什麼問題。 http://apps.facebook.com/biographyscribe/Facebook的授權及登錄
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US"
xmlns:fb="https://www.facebook.com/2008/fbml">
<head>
<title></title>
</head>
<body>
<p>hello</p>
<script type="text/javascript">
window.fbAsyncInit = function() {
FB.init({
appId : '490455294310717', // App ID from the App Dashboard
channelUrl: 'channel.php',
status : true, // check the login status upon init?
cookie : true, // set sessions cookies to allow your server to
xfbml : true // parse XFBML tags on this page?
});
// Additional initialization code such as adding Event Listeners goes here
FB.getLoginStatus(function(response) {
if (response.status === 'connected') {
var uid = response.authResponse.userID;
accessToken = response.authResponse.accessToken;
} else if (response.status === 'not_authorized'){
FB.login();
} else {
window.top.location = 'https://www.facebook.com/index.php';
}
});
};
// Load the SDK's source Asynchronously
(function(d, debug){
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" + (debug ? "/debug" : "") + ".js";
ref.parentNode.insertBefore(js, ref);
}(document, /*debug*/ false));
</script>
<div id="fb-root"></div>
</body>
</html
>
當你運行它時,你會得到任何javascript錯誤嗎?什麼是輸出?您是否嘗試過在腳本標籤上方移動
? – TommyBs彈出式窗口攔截器?它建議僅在顯式用戶交互時調用FB.login - 您只是在加載頁面時調用它。 – CBroe