Log out from facebook

我只是一个虾纸丫 提交于 2020-01-03 04:30:06

问题


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!


回答1:


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


来源:https://stackoverflow.com/questions/7771821/log-out-from-facebook

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!