Search code examples
c#asp.netjsontwittertwitterizer

How can I get the Twitter follower screenNames of a given Username with Twitterizer?


OAuthTokens tokens = new OAuthTokens();
tokens.AccessToken = "188817262xxxxx";
tokens.AccessTokenSecret = "GNqhB1gkxxxx";
tokens.ConsumerKey = "Q6xxxxx";
tokens.ConsumerSecret = "2eZyxxxxxx";

var<TwitterUser> showUserResponse = TwitterUser.Show(tokens, "twitterUsername");
if (showUserResponse.Result == RequestResult.Success)
    {
    string screenName = showUserResponse.ResponseObject.ScreenName;
    Response.Write(screenName);
    Response.Write("<br>");
    Response.Write(showUserResponse.ResponseObject.NumberOfFollowers);
    }

With this code I can get my Twitter screenName and numberOfFollowers, but I want to print those follower screenNames on my asp.net application. How can I achieve that?

FollowersOptions options = new FollowersOptions();
options.ScreenName = "wallace740";
TwitterResponse<TwitterUserCollection> followers = TwitterFriendship.Followers(options);

// Response.Write(followers.Content);

How can I get the screenNames of my followers from this JSON (followers.Content gives me a JSON result)?


Solution

  • You can enumerate through the ReponseObject.

            foreach (var follower in followers.ResponseObject)
            {
                follower.ScreenName;
            }