从Facebook登出 [英] Log out from facebook

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

问题描述

好,我开发一个Flex桌面应用程序,我不能退出表单Facebook。我的意思是在登录并更新我想要更新的照片后,我运行方法注销,看起来像这样

  FacebookDesktop.logout(handleLogout); 

其中handleLogout是我可以做其他事情的功能。



该方法运行但不会注销。我认为可能加载其他请求我可以注销,我发现使用:


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


注销,但我不知道我在哪里得到accesToken。



提前感谢

解决方案

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



说明



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

  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&安培;代码= +的Request.QueryString [ 代码]);
}
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. 分别使用 AppId AppSecret 替换 CLIENT_ID,APP_SECRET / li>
  4. CURRENT_URL 应该是您正在实施代码的网页的URL。

  5. 部分 & scope = read_stream 不是强制性的。如果您需要任何其他权限,请在此处输入逗号分隔值。

您将获得格式为

的字符串

access_token = ACCESS_TOKEN_VALUE& expires = EXPIRY_TIME



作为响应。






尝试使用flex发送POST请求

  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);


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);

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"

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

Thanks in advance!

解决方案

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

EXPLANATION

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");
     }
}

HERE IS THE PROCEDURE

  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

as response.


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);

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

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