为什么TweetSharp总是只返回100个关注者? [英] Why does TweetSharp always return only 100 followers?

查看:99
本文介绍了为什么TweetSharp总是只返回100个关注者?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在.NET 4(C#)应用程序中使用 TweetSharp 库.

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);
    }
}

代码运行良好,但使用断点,我发现即使用户有100个以上的关注者(我在官方网站上查看),我的应用程序中的对象也只有100个.

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.

是否可以使用TweetSharp为Twitter用户获取所有关注者?

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

推荐答案

您需要通过光标:

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);
    }
}

您可以在一些测试中看到它: https://github.com/danielcrenna/tweetsharp/blob/master/src/net40/TweetSharp.Next.Tests/Service/TwitterServiceTests.cs

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

这篇关于为什么TweetSharp总是只返回100个关注者?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆