简体   繁体   English

如何使用JavaScript清除Facebook会话?

[英]How to clear facebook session using javascript?

Original Question: Facebook logout URL not working 2014?? 最初的问题: Facebook注销URL在2014年不起作用?

Well I tried to logout, a user from facebook using url but isn't working, I used this URL: 好吧,我尝试注销,一个使用url从facebook上的用户,但无法正常工作,我使用了以下URL:

https://www.facebook.com/logout.php?confirm=1&next=http://www.foo.com&access_token=XX https://www.facebook.com/logout.php?confirm=1&next=http://www.foo.com&access_token=XX

Answer: The problem why url wasn't working is that access_token=xxxx**&expiresIn=123** , the expiresIn parameter tagging along was the main reason why the URL wasn't working, but I ended up using the JS SDK anyway. 答:为何URL无法正常工作的问题是access_token = xxxx **&expiresIn = 123 **,expiresIn参数标记是URL无法正常工作的主要原因,但无论如何我还是使用了JS SDK。 But still I am having problems can anyone help me with the updated issue I have mentioned below. 但是我仍然遇到问题,任何人都可以在下面提到的更新问题上为我提供帮助。

I have a situation where I can't use the javascript alternative. 我遇到无法使用javascript替代方案的情况。 As I haven't been using Javascript SDK to login users to begin with. 因为我从未使用过Javascript SDK来登录用户。 The application I am building is in Scala, so I haven't any SDK, just urls. 我正在构建的应用程序在Scala中,因此我没有任何SDK,只有URL。

@ Update : Well I solved my problem of logging out people using my app, by using the facebook javascript SDK, it just loads the sdk and calls the logout api, code snippet below. @ Update :好吧,我解决了使用我的应用程序注销用户的问题,通过使用facebook javascript SDK,它仅加载了sdk并调用了注销api(以下代码段)。

But Still I am having problems, ie if users login to my app using their facebook account but then don't give permission to my FB app at the permission dialog then there will be an active facebook session running and no way to clear it or log him/her out (i am building a KIOSK APP so it will be a deadlock condition). 但是我仍然遇到问题,即如果用户使用他们的Facebook帐户登录到我的应用程序,但是又没有在权限对话框中授予我的FB应用程序许可,那么将有一个活动的 Facebook会话正在运行,无法清除或登录他/她出去(我正在构建一个KIOSK APP,因此它将处于死锁状态)。

I can't log them out using the Logout API , so how do I clear the session. 我无法使用Logout API登出 ,因此如何清除会话。 I checked various SO posts to clear session cookies but none seem to work. 我检查了各种SO帖子以清除会话cookie,但似乎没有任何作用。

window.fbAsyncInit = function() {
  FB.init({
    appId      : 'xxxxxx',
    cookie     : true,  // enable cookies to allow the server to access 
                        // the session
    xfbml      : true,  // parse social plugins on this page
    version    : 'v2.1' // use version 2.1
  });
  FB.getLoginStatus(function(response) {
    if (response && response.status === 'connected') {
                FB.logout(function(response) {
                    document.location.reload();
                });
            }
  });
  };

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

It seems there are kiosk apps for ipad at least, which provide options to clear browser session automatically. 似乎至少有适用ipad的 信息亭应用程序 ,这些应用程序提供了自动清除浏览器会话的选项。 So, if you are creating app for kiosks using ipad at least app are available which can solve the issue 因此,如果您要使用ipad为信息亭创建应用,至少可以使用可以解决问题的应用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM