调用FB.logout()没有访问令牌 [英] FB.logout() called without an access token

查看:1738
本文介绍了调用FB.logout()没有访问令牌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试注销使用Facebook集成的网站。
登录工作正常,但是当我想要注销Firebug时,一直给我这个错误:

I'm trying to log out of a website i've created with Facebook integrated. Logging in works fine, but when I want to log out Firebug consistently gives me this error:

FB.logout()调用没有访问令牌。

我正在使用Facebook JavaScript SDK,我必须注销的代码如下所示: / p>

I'm using the Facebook JavaScript SDK, and the code I've got to logout looks like this:

$(document).ready($(function () {
    $("#fblogout").click(facebooklogout);
}));

function facebooklogout() {
    FB.logout(function (response) {
    }
)};

这是在 Facebook开发人员文档只需在document.ready上分配一个按钮。

This is the logout code specified at the Facebook Developers Documentation just with a button being assigned the method on document.ready

在此之前代码我有 FB.init()方法,这一切都运行正常。

Before this code I have the FB.init() method, that all runs fine.

如果有人有解决方案为什么FB.logout没有访问令牌,不胜感激。

If anyone's got a solution as to why FB.logout doesn't have an access token, it'd be appreciated.

推荐答案

从应用程序注销使用Facebook图形API,在< form> 标签之后的注销页面上使用此JavaScript:

To logout from the application which uses facebook graph API, use this JavaScript on the logout page just after the <form> tag:

window.onload=function()
{
    // initialize the library with your Facebook API key
    FB.init({ apiKey: 'b65c1efa72f570xxxxxxxxxxxxxxxxx' });

    //Fetch the status so that we can log out.
    //You must have the login status before you can logout,
    //and if you authenticated via oAuth (server side), this is necessary.
    //If you logged in via the JavaScript SDK, you can simply call FB.logout()
    //once the login status is fetched, call handleSessionResponse
    FB.getLoginStatus(handleSessionResponse);
}

//handle a session response from any of the auth related calls
function handleSessionResponse(response) {
    //if we dont have a session (which means the user has been logged out, redirect the user)
    if (!response.session) {
        window.location = "/mysite/Login.aspx";
        return;
    }

    //if we do have a non-null response.session, call FB.logout(),
    //the JS method will log the user out of Facebook and remove any authorization cookies
    FB.logout(handleSessionResponse);
}

该代码适用于我的网站。

The code works and is live on my site.

这篇关于调用FB.logout()没有访问令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆