简体   繁体   English

C# - 检查用户是否登录Facebook

[英]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). 我正在开发Windows Phone Silverlight应用程序,我想通过Facebook(浏览器)进行简单登录。 Is there a way to check if the user is logged in Facebook? 有没有办法检查用户是否登录Facebook? I redirect the user to Facebook page with this statement: 我使用以下语句将用户重定向到Facebook页面:

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. 我不知道你是否使用windows SDK for facebook( https://github.com/Microsoft/winsdkfb ),但它是Facebook批准的第三方sdk。

Before using that SDK you should set up the Facebook developer page for your app. 在使用该SDK之前,您应该为您的应用设置Facebook开发者页面。 ( https://developers.facebook.com/docs/apis-and-sdks ) 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 下面是一个WPF示例,它使用WebBrowser类来获取令牌: WPF和C#中的Facebook OAuth示例

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. 显然,WPF相关的东西可能会有所不同,但它至少应该指向您从过程中获取所需的信息。 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). 至于检查用户是否已登录,我几乎只是通过制作一些使用它的http请求并查看它是否成功来检查令牌是否有效(使用REST客户端)。

There was a way to directly check token validity via the Facebook APIs but that was deprecated last I checked. 有一种方法可以通过Facebook API直接检查令牌有效性,但最后我检查过这种方法已被弃用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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