c# - 如何确定 Facebook 用户是否登录到 Facebook 从 C# 连接

标签 c# asp.net-mvc api facebook

我想知道当前用户是否使用他们的 Facebook 帐户登录我的网站...

我尝试四处搜索并查看 facebook 命名空间,但没有找到任何类似于 isUserLoggedIn() 的内容。

我猜我在某个地方漏掉了它...有人知道适用于此的方法吗?

最佳答案

检查 session key cookie。

    public static string SessionKey
    {
        get { return GetFacebookCookie("session_key"); }
    }

    private static string GetFacebookCookie(string propertyName)
    {
        var fullName = ApiKey + "_" + propertyName;

        if (HttpContext.Current == null || HttpContext.Current.Request.Cookies[fullName] == null)
            return null;

        return HttpContext.Current.Request != null ? HttpContext.Current.Request.Cookies[fullName].Value : null;
    }

关于c# - 如何确定 Facebook 用户是否登录到 Facebook 从 C# 连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1225675/

相关文章:

c# - SQL Server 连接计数问题

c# - C#的统计收集工具?

asp.net-mvc - 将枚举传递给 MVC3 的 html.radiobutton

asp.net-mvc - 需要 ASP.NET MVC AutoEventWireup 吗?

asp.net - 如何防止用户操纵html内容 "badly"并将其发布回服务器?

iOS 扩展和受限 API

C# 查找套接字 ID?

c# - Entity Framework 是否需要预取路径?

php - Steam Web API 获取徽章图像 URL

php - file_get_contents() 移除 XML 标签