admin 管理员组文章数量: 1086019
I'm trying to check whether a user is logged in to Facebook (just logged in or not, with no relation to my application) using javascript.
I tried using the following code after FB.init:
FB.getLoginStatus(function(response) {
alert(response.status);
});
edge.create is working just fine though.
I'm trying to check whether a user is logged in to Facebook (just logged in or not, with no relation to my application) using javascript.
I tried using the following code after FB.init:
FB.getLoginStatus(function(response) {
alert(response.status);
});
edge.create is working just fine though.
3 Answers
Reset to default 6There are some hacks that can help, but not in your situation. https://grepular./Abusing_HTTP_Status_Codes_to_Expose_Private_Information
Here is simple example:
<html>
<head>
</head>
<body>
// At the end of page will be good
<script>
function logged() {
alert('logged');
}
function notlogged() {
alert('not logged');
}
</script>
<script src="http://www.facebook./ajax/poser/attachment/question/question.php" onload="logged()" onerror="notlogged()">
</body>
</html>
if (FB.getSession() != null) {
FB.api('/me', function(response){
alert ("Wele " + response.name);
})
}
With one caveat, though: the user needs to authorize your app in order to detect whether is logged in or not. I believe there is no way to detect it without it with this api: You can add a like button and such, but not interact with the fb status.
http://developers.facebook./docs/guides/web/
FB.getLoginStatus(function(response) {
if (response.authResponse) {
// alert('Wele! Fetching your information.... ');
FB.api('/me', function(response) {
alert('Good to see you, ' + response.name + '.');
});
}
});
本文标签: javascriptCheck if a user is logged in to FacebookStack Overflow
版权声明:本文标题:javascript - Check if a user is logged in to Facebook - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://roclinux.cn/p/1744008528a2517723.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论