Twitter 获取给定用户在LinqToWitter中跟踪的用户(而不是跟随者)

Twitter 获取给定用户在LinqToWitter中跟踪的用户(而不是跟随者),twitter,linq-to-twitter,Twitter,Linq To Twitter,如何获取给定用户在LinqToTwitter中跟踪的用户(而非追随者)的用户名和屏幕名 ?? twitterapi使用follower这个词来表示关注用户的人,朋友则表示用户关注的人,linqtotwitter继续使用这种方法。因此,您可以使用友谊/友谊类型。友谊列表查询,如下所示: static async Task FriendsListAsync(TwitterContext twitterCtx) { Friendship friendship;

如何获取给定用户在LinqToTwitter中跟踪的用户(而非追随者)的用户名和屏幕名

??

twitterapi使用follower这个词来表示关注用户的人,朋友则表示用户关注的人,linqtotwitter继续使用这种方法。因此,您可以使用
友谊
/
友谊类型。友谊列表
查询,如下所示:

    static async Task FriendsListAsync(TwitterContext twitterCtx)
    {
        Friendship friendship;
        long cursor = -1;
        do
        {
            friendship =
                await
                (from friend in twitterCtx.Friendship
                 where friend.Type == FriendshipType.FriendsList &&
                       friend.ScreenName == "JoeMayo" &&
                       friend.Cursor == cursor &&
                       friend.Count == 200
                 select friend)
                .SingleOrDefaultAsync();

            if (friendship != null && 
                friendship.Users != null && 
                friendship.CursorMovement != null)
            {
                cursor = friendship.CursorMovement.Next;

                friendship.Users.ForEach(friend =>
                    Console.WriteLine(
                        "ID: {0} Name: {1}",
                        friend.UserIDResponse, friend.ScreenNameResponse)); 
            }

        } while (cursor != 0);
    }
此示例在
do
/
while
循环中遍历结果。请注意,
光标
设置为
-1
,这将在没有Twitter API光标的情况下启动查询。每个查询分配
光标
,该光标将获得下一页的用户。在
if
块中,第一条语句读取
Friendly.CursorMovement.Next
以获取下一页用户的
光标。当下一个
光标
0
时,您已经阅读了所有跟随者

执行查询后,
Users
属性有一个
列表
,您可以从中获取用户信息。此演示将打印列表中的每个成员

你可能会遇到的一个问题是,推特会返回一个超过速率限制的错误。您可以在
try
/
catch
块中捕获此消息,方法是捕获
TwitterQueryException
并检查超出速率限制的属性。要最小化费率限制问题,请将
count
设置为
200
,否则最大计数默认为20


您可以在LINQ to Twitter网站上下载并查看此信息。

非常感谢您的及时回复。我并没有太多的时间去查看LINQ和Twitter来了解这一点,但毫无疑问,这是一个非常有用的、做得很好的产品。我想代表所有开发人员感谢您为构建它所做的努力。无法编辑它,但在“friend.Cursor==Cursor”之后缺少“&&”,谢谢。