Tuesday, November 8, 2011

Facebook Auth Logout for Windows Phone 7

In some situations, you may want to allow user to change their account, it is easy to do that.
The Doc of  facebook refers to

Logout
You can log a user out of their Facebook session by directing them to the following URL:
https://www.facebook.com/logout.php?next=YOUR_URL&access_token=ACCESS_TOKEN
Note: YOUR_URL must be a URL in your site domain, as defined in the Developer App.

According to this, you can make your request Url be following form:
https://www.facebook.com/logout.php?next=YOUR_URL&access_token=ACCESS_TOKEN

But the major question is what YOUR_URL should be?


First, open https://developers.facebook.com/, then go to Application page.
In my case, I put the-asquare.com to be App domain, and http://the-asquare.com be Website Url. You can replace App domain and website Url to whatever you need. Just notice that your website Url must in your App domain. If you don't have and App domain or you want to make it more simple(e.g. not redirect to any URL), just let App domain be www.facebook.com and Websit Url be http://www.facebook.com.

Then in your code just like this
string token = appAccess_token;
string next = "http://www.facebook.com";

brower.Navigate(new Uri(string.Format("https://www.facebook.com/logout.php?next={0}&access_token={1}", next, token), UriKind.Absolute));

No comments:

Post a Comment