简体   繁体   中英

Finding a user's Twitter profile details 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.
}

Code source .

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.

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

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