使用 DotNetOpenAuth 查找用户的 Twitter 个人资料详细信息
我如何找到以下详细信息:
- 语言
- 配置文件 图像 URL
- 时区
我使用此代码仅进行身份验证。回调效果很好!
如何超越 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.
}
代码来源。
How can I find details like:
- language
- profile image URL
- time zone
I'm using this code to authenticate only. The callback works great!
How can I go beyond authentication with DotNetOpenAuth to get the profile details?
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.
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您只是想验证用户身份并检索他们的数据,我会使用类似 TweetSharp 的东西。您可以作为 Web 应用程序或桌面应用程序对用户进行身份验证,并且您可以访问用于检索用户详细信息、关系、提及等的方法。这比尝试自己解析 Twitter 响应要快得多。
以下是他们的文档,展示了 TweetSharp 使用起来有多么简单:http://tweetsharp.codeplex.com/documentation
或者,您可以像现在一样继续进行身份验证,并仅使用 TweetSharp(带有用户访问令牌)来提取您想要的数据。
编辑为您的问题添加更多具体信息:
TweetSharp 提供了一种方法 GetUserProfileFor(int userId) ,该方法返回 TwitterUser 对象,其中包含其时区、个人资料图像 url、语言、位置等。
If you're just trying to authenticate a user and retrieve their data, I'd use something like TweetSharp. You can authenticate users either as a web application or a desktop application, and you'll have access to methods for retrieving user details, relationships, mentions, etc. This will be a lot faster than trying to parse the Twitter responses yourself.
Here is their documentation, which shows how easy TweetSharp is to use: http://tweetsharp.codeplex.com/documentation
Alternatively, you can keep authenticating as you are now, and just use TweetSharp (with the users access token) to pull the data you want.
Edited to add more specific info for your question:
TweetSharp offers a method GetUserProfileFor(int userId) that returns a TwitterUser object, that contains their TimeZone, profile image url's, langauge, location, etc.
我一直在研究这个问题,到目前为止我发现的内容如下。有一个站点提供了有关如何使用 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
I've been looking into this and what I have found so far is the following. There is a site that provides an ASP.NET tutorial on how to set up a connection using DotNetOpenAuth. Here is the link to it:
http://bhaidar.net/post/2011/04/04/OpenID-Single-Sign-On-ASPNET-Web-Forms.aspx
Here is a site that it linked to in order to find extended information on what might be provided for the download:
http://openid.net/specs/openid-simple-registration-extension-1_0.html