Quit Facebook C # SDK on WP7

I am trying to add a function to exit the system that is called in the click event of ApplicationBarMenuItem, following the instructions in this blog

This is what my code looks like:

var oauth = new FacebookOAuthClient(); var logoutParameters = new Dictionary<string, object> { { "next", "http://www.facebook.com" } }; var logoutUrl = oauth.GetLogoutUrl(logoutParameters); LayoutRoot.Children.Add(FacebookLoginBrowser); FacebookLoginBrowser.Navigate(new Uri(logoutUrl.AbsoluteUri, UriKind.Absolute)); 

What I expected from this code is to logout the user from Facebook when the Navigated event completes and then displays any URL in the parameter (in this case facebook.com). However, I see that it always downloads β€œ http://m.facebook.com/ ” no matter what is transmitted and does not exit Facebook, I don’t care what it downloads after (it would be great, but for now I just want him to perform the logout action so that the user can log out and log in when he starts my application again). The only way I can successfully log out of the system is to understand when the page that they need to scroll down loads, zoom in and click "log out" manually at the bottom of the page, which is simply unacceptable to the user.

I also downloaded sample code from this blog and did about the same.

I saw this and this post , and the URL used is pretty close to what oath.GetLogoutUrl (logoutParameters) returns, but I tried to build the exact URL with the same result:

 var logoutUrl = new Uri("https://www.facebook.com/logout.php?next=http://www.facebook.com&access_token="+fbClient.AccessToken); 

This is definitely a cork for my application, so any help or suggestions anyone can provide will be greatly appreciated!

+6
source share
3 answers

It turns out that the problem is that the domain in the redirect URL does not match the domain domain specified in the application settings on Facebook. Obviously, no one could see this, because you do not have access to the settings of my application, but it is a bit like my application cannot be registered on "http://www.facebook.com" (like I have that domain must be unique).

The solution is to use my own site in the next parameter, which in my case is thecruxapp.com. In addition, session_key and api_key are needed, so in the end the code that worked for me was:

 string logout_format = "http://www.facebook.com/logout.php?api_key={0}&session_key={1}&next={2}"; string access_token = HttpUtility.UrlDecode(fbClient.AccessToken); char[] tokenSeparator = new char[] { '|' }; string session = access_token.Split(tokenSeparator)[1]; FacebookLoginBrowser.Navigate(new Uri(string.Format(logout_format, apiKey, HttpUtility.UrlEncode(session), HttpUtility.UrlEncode("http://thecruxapp.com")))); 

I do not experience an error related to another answer, and it was not connected - both exits and redirects just fine, as long as the URL passed to the next parameter matches the site domain entered in the application settings on Facebook.

+1
source

It seems to be broken on the Facebook side: http://bugs.developers.facebook.net/show_bug.cgi?id=17217

+2
source

The same problem does not have a web application as a backend for my WP7 application. I found this solution useful http://claudiufarcas.blogspot.com/2011/06/wp7-webbrowser-caching-and-facebook.html , but made some changes to the code since some changes to the HTML were made since publication facebook made document.

this worked for me http://blog.jocelynenglund.com/?p=21

0
source

Source: https://habr.com/ru/post/889801/


All Articles