2017-10-09 82 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。