I'm using TweetSharp in a WPF .NET 4.0 C# app and using an authenticated Twitter service object. I'm having issues iterating through a list of followers to retrieve every single profile. I'm using the following code:
TwitterCursorList<TwitterUser> followers = twitterService.ListFollowersOf(userID, -1);
while (followers != null)
{
foreach (TwitterUser follower in followers)
{
//Do something with the user profile here
}
followers = twitterService.ListFollowersOf(userID, (long)followers.NextCursor);
}
I see a weird behavior when I use this against my own account, which has 1271 followers as of this writing. The 1st time I run the code, I get a list of 100 followers, and on the next ListFollowersOf call, followers is null and the loop ends.
Here is the weird part: If I run this code again, whether in the same app instance, or if I stop Visual Studio and restart, doesn't matter, I get one extra ieration and now I get 200 followers back. If I do this trick again, now I get 300 followers back before I get a null, and so on. I repeated this many times until one call of the code above returned all 1271 followers.
The really weird thing is this eventually resets. I think it's tied to the Twitter API limit reset time, but I have not verified that. I'll see if this coincides with the API reset. Once the reset happens, I only get 100 followers, then 200, and so on.
I have reviewed TweetSharp unit tests and the following posts and they did not work for me: