2

I'm using the TweetSharp library in a .NET 4 (C#) application.

Here is a helper method I built that returns followers for a given user.

public static void FindFollowersForUser(TwitterUserModel twitterUser)
{
                                            //A simple string for screen name.
    var followers = service.ListFollowersOf(twitterUser.TwitterName);
    foreach (var follower in followers)
    {
                   //Followers is a simple List<string>.
        twitterUser.Followers.Add(follower.ScreenName);
    }
}

The code runs fine but using breakpoints I see that even if the user has more than 100 followers (I check on the official site), the object in my application has only 100.

Is there a way to get all of the followers for a twitter user using TweetSharp?

Only Bolivian Here
  • 35,719
  • 63
  • 161
  • 257

1 Answers1

7

You need to go through the cursor:

var followers = service.ListFollowersOf(twitterUser.TwitterName, -1);
while (followers.NextCursor != null)
{
    followers =  service.ListFollowersOf(user_id, followers.NextCursor);
    foreach (var follower in followers)
    {
         twitterUser.Followers.Add(follower.ScreenName);
    }
}

You can see this in some of the tests: https://github.com/danielcrenna/tweetsharp/blob/master/src/net40/TweetSharp.Next.Tests/Service/TwitterServiceTests.cs

yamen
  • 15,390
  • 3
  • 42
  • 52