我对Stackoverflow和编码很新,但我会尽力使这个问题尽可能简单明了:
我正在寻找创建一个网页,其中我有一个Facebook赞按钮和一个退出按钮,用户可以在Facebook帐户中签名...所以用户可以Facebook喜欢,输入登录信息,然后退出。这是我到目前为止的脚本,但我已刷新,以便注销工作并直接返回主页面。非常感谢您的帮助:
互动链接:http://jsfiddle.net/nrdnx/11/
代码:
<html>
<head>
<title>My Great Web page</title>
</head>
<body>
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : '271358172932770', // App ID
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
// Additional initialization code here
getStatus();
};
// Load the SDK Asynchronously
(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));
</script>
</script>
<iframe src="http://www.facebook.com/plugins/like.php?href=www.facebook.com/orangeleaflawrence"
scrolling="no" frameborder="0"
style="border:none; width:450px; height:80px"></iframe>
<a href="javascript:void();" onclick="getStatus()">Get Status</a>
<div id="logout"><a href="logout.html">Logout of Facebook</a></div>
<script>
FB.Event.subscribe('auth.authResponseChange', function(response) {
alert('The status of the session is: ' + response.status);
});
function getStatus(){
FB.getLoginStatus(function (response) {
alert(response.status);
if (response.status === 'connected') {
document.getElementById('logout').style.display='';
// the user is logged in and has authenticated your
// app, and response.authResponse supplies
// the user's ID, a valid access token, a signed
// request, and the time the access token
// and signed request each expire
} else if (response.status === 'not_authorized') {
document.getElementById('logout').style.display='none';
// the user is logged in to Facebook,
// but has not authenticated your app
} else {
// the user isn't logged in to Facebook.
document.getElementById('logout').style.display='none';
}
}
);
}
</script>
</body>
</html>
答案 0 :(得分:0)
我不确定我的问题是什么,但是注销sdk功能在这里: http://developers.facebook.com/docs/reference/javascript/FB.logout/