从Facebook登出 [英] Log out from 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 );
}
}
这里是程序
- 创建asp.net网站
- 在 default.aspx 页面实现上述代码。
- 分别使用 AppId 和 AppSecret 替换 CLIENT_ID,APP_SECRET / li>
- CURRENT_URL 应该是您正在实施代码的网页的URL。
- 部分 & 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
- Create an asp.net website
- In the default.aspx page implement the above code.
- Replace CLIENT_ID,APP_SECRET with the AppId and AppSecret respectively
- CURRENT_URL should be the url of the page in which you are implementing the code.
- 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屋!