【问题标题】:Finding a user's Twitter profile details with DotNetOpenAuth使用 DotNetOpenAuth 查找用户的 Twitter 个人资料详细信息
【发布时间】:2011-08-14 10:10:54
【问题描述】:

如何找到以下详细信息:

  • 语言
  • 个人资料图片网址
  • 时区

我仅使用此代码进行身份验证。回调效果很好!

如何通过 DotNetOpenAuth 进行身份验证以获取配置文件详细信息?

public bool FinishAuthentication()
{
    using (var twitter = new WebConsumer(ServiceDescription, _tokenManager))
    {
        var accessTokenResponse = twitter.ProcessUserAuthorization();
        if (accessTokenResponse != null)
        {
            string userName = accessTokenResponse.ExtraData["screen_name"];
            string id = accessTokenResponse.ExtraData["user_id"];

//-----how can we get all the other profile info?-----
            GetProfileDetails(id);
            return true;
        }
    }

    return false;
}
public void GetProfileDetails(string id)
{
  //unsure how to implement with DotNetOpenAuth.
}

Code source.

【问题讨论】:

    标签: c# .net twitter dotnetopenauth


    【解决方案1】:

    如果您只是想对用户进行身份验证并检索他们的数据,我会使用 TweetSharp 之类的东西。您可以通过 Web 应用程序或桌面应用程序对用户进行身份验证,并且可以访问用于检索用户详细信息、关系、提及等的方法。这将比尝试自己解析 Twitter 响应快得多。

    这是他们的文档,展示了 TweetSharp 的易用性:http://tweetsharp.codeplex.com/documentation

    或者,您可以像现在一样继续进行身份验证,只需使用 TweetSharp(带有用户访问令牌)来提取您想要的数据。

    编辑为您的问题添加更具体的信息:

    TweetSharp 提供了一个 GetUserProfileFor(int userId) 方法,该方法返回一个 TwitterUser 对象,其中包含他们的时区、个人资料图片网址、语言、位置等。

    【讨论】:

    • 谢谢!我肯定会考虑将 API 切换到 TweetSharp!
    【解决方案2】:

    我一直在研究这个问题,到目前为止我发现如下。有一个站点提供了有关如何使用 DotNetOpenAuth 建立连接的 ASP.NET 教程。这是它的链接:

    http://bhaidar.net/post/2011/04/04/OpenID-Single-Sign-On-ASPNET-Web-Forms.aspx

    这是一个链接到的站点,以便查找有关可能提供的下载内容的扩展信息:

    http://openid.net/specs/openid-simple-registration-extension-1_0.html

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-01-13
      • 1970-01-01
      • 2018-10-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多