从脸书登出 [英] Log out from facebook

查看:27
本文介绍了从脸书登出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,我正在开发 Flex 桌面应用程序,但我无法从 Facebook 注销.我的意思是在登录并更新我要更新的照片后,我运行注销方法,如下所示

Well i developing a Flex desktop app and i cant logout form facebook. I mean after loggin in and updating the photo i want to update, i run the method to log out, which looks like this

FacebookDesktop.logout(handleLogout);

handleLogout 是一个我可以做其他事情的函数.

Where handleLogout is a function where i can do other things.

该方法运行但从未注销.我认为也许加载其他请求我可以注销,我发现使用:

The method runs but never log out. I think that maybe loading an other request i could log out, and i find that using:

"https://www.facebook.com/logout.php?"+ info.get_accessToken() +"&next=http://www.Google.com"

"https://www.facebook.com/logout.php?" + info.get_accessToken() + "&next=http://www.Google.com"

会注销,但我不知道从哪里可以获得 accesToken.

would log out, but i dont know where i ca get the accesToken.

提前致谢!

推荐答案

以下代码是在for asp.net页面中使用C#代码实现的.

The following code is implemented in for asp.net page using C# code.

说明

首先您需要发送一个请求来验证用户(IF 部分).成功验证后,您将获得代码".然后使用此代码发送请求以授权应用程序.成功授权后,您将获得访问令牌作为响应.

First you need to send a request to authenticate the user(the IF part). You will get a "CODE" on successfull authentication. Then send a request with this code to authorize the application. On successful authorization you will get the access token as response.

protected void Page_Load(object sender, EventArgs e)
{
    if (Request.QueryString["code"] != null)
    {
        Response.Redirect("https://graph.facebook.com/oauth/access_token?client_id=CLIENT_ID&redirect_uri=CURRENT_URL&client_secret=APP_SECRET&code="+Request.QueryString["code"]);
     }
     else
     {
        Response.Redirect("https://www.facebook.com/dialog/oauth?client_id=CLIENT_ID&redirect_uri=CURRENT_URL&scope=read_stream");
     }
}

流程如下

  1. 创建一个 asp.net 网站
  2. default.aspx页面中实现上述代码.
  3. CLIENT_ID,APP_SECRET 分别替换为 AppIdAppSecret
  4. CURRENT_URL 应该是您在其中实施代码的页面的网址.
  5. &scope=read_stream"部分不是强制性的.如果您需要任何其他权限,请在此处以逗号分隔值的形式输入.
  1. Create an asp.net website
  2. In the default.aspx page implement the above code.
  3. Replace CLIENT_ID,APP_SECRET with the AppId and AppSecret respectively
  4. CURRENT_URL should be the url of the page in which you are implementing the code.
  5. The part "&scope=read_stream" is not mandatory. If you need any additional permissions please enter it here as comma separated values.

你会得到一个格式的字符串

You will get a string in the format

access_token=ACCESS_TOKEN_VALUE&expires=EXPIRY_TIME

作为回应.

尝试使用 flex 发送 POST 请求

Try this to send a POST request using flex

var urlLoader:URLLoader = new URLLoader();
var request:URLRequest = new URLRequest("https://www.facebook.com/logout.php?next=YOUR_URL&access_token=ACCESS_TOKEN");
request.data = binaryData;
request.method = URLRequestMethod.POST
urlLoader.load(request);

这篇关于从脸书登出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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