简体   繁体   中英

C# - Check if user is logged in Facebook

I'm working on a Windows Phone Silverlight app and I want to make a simple login via Facebook(browser). Is there a way to check if the user is logged in Facebook? I redirect the user to Facebook page with this statement:

Launcher.LaunchUriAsync(new Uri("http://www.facebook.com"));

I don't know if you are using the windows SDK for facebook ( https://github.com/Microsoft/winsdkfb ) but it is a third party sdk approved by Facebook.

Before using that SDK you should set up the Facebook developer page for your app. ( https://developers.facebook.com/docs/apis-and-sdks )

I hope that helps.

Here is a WPF example that uses the WebBrowser class to get a token: Facebook OAuth in WPF & C# Example

Obviously the WPF related things might differ a bit, but it should at least point you to getting the info you need out of the process. As far as checking whether the user is logged in, I pretty much just checked whether the token is valid by making some http request that uses it and seeing whether it was successful (used a REST client for that).

There was a way to directly check token validity via the Facebook APIs but that was deprecated last I checked.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM