Logging out of Facebook WP7

Building a WP7 application with facebook and I’ve been using the Facebook C#SDK  which was fine till I wanted to enable logging out of my application. I found this post helpful

http://claudiufarcas.blogspot.com/2011/06/wp7-webbrowser-caching-and-facebook.html

but changed the code a bit as facebook was returning a different HTML from when this code was probably created

private void wb_Navigated(object sender, NavigationEventArgs e)    {
 string fbLogoutDoc = wb.SaveToString().ToLower();
 Regex regex = new Regex
 ("\\<A href=\\\"/logout(.*)\\\".*data-sigil=\\\"logout\\\"");
 MatchCollection matches = regex.Matches(fbLogoutDoc);
 if (matches.Count > 0)      {
  string finalLogout = string.Format
   (http://m.facebook.com/logout{0},
    matches[0].Groups[1].ToString());
  wb.Navigate(new Uri(finalLogout));
  }
}

Leave a Reply