2017-10-09 77 views
1

我正在尝试检测用户是否遵循我的帐户或特别是关于此事的任何其他帐户。LinqToTwitter检查用户是否关注你

到目前为止:

var user = await (from u in Session.service.User 
        where u.Type == UserType.Lookup && u.ScreenNameList == f.ScreenName 
        select u).ToListAsync(); 

         if (user != null) 
         { 
          foreach (User u in user) 
          { 
           Cutil.Line("<Follow Check> - " + u.ScreenNameResponse + " is " + u.Following, ConsoleColor.Blue); 
          } 
         } 

我可以找出我的帐户如下别人的地方,但我怎么能反其道而行之?

编辑:还有另一个类似的问题,其中涉及获取其他用户的追随者列表 - 在许多情况下,这将是足够的,因为你可以只搜索该列表,看看是否X帐户是在它上面。但是,它有其缺点,因为您可以访问Twitter的次数有限制,并且该方法一次只能产生5000个用户(如果某人拥有一百万个关注者,这不太实际)。

因此,这个问题是专门询问是否存在像User.Buffer这样的布尔值,如果你被跟踪回来,那么返回true。

other question似乎与返回其他用户所关注的人员列表有关。

+0

可能的重复[查找所有使用Linq to Twitter的用户的追随者?](https://stackoverflow.com/questions/10724064/find-all-followers-for-a-user-using-linq-to-推特) – hellyale

回答

0
var friendships = await (from friendship in Session.service.Friendship 
         where friendship.Type == FriendshipType.Show && friendship.SourceScreenName == "twittername" && friendship.TargetScreenName == "othertwittername" 
         select friendship).ToListAsync(); 

if (friendships != null) 
{ 
    foreach (Friendship friend in friendships) 
    { 
     Console.WriteLine(friend.SourceRelationship.FollowedBy); 
    } 
} 

这将得到是否给定的用户跟随另一个给定的用户,true或false。