【问题标题】:LinqToTwitter check if a user follows youLinqToTwitter 检查用户是否关注您
【发布时间】:2018-03-20 21:50:41
【问题描述】:

我正在尝试检测用户是否关注我的帐户,或任何其他帐户,特别是与此相关的。

到目前为止:

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 个用户(如果有人有 100 万粉丝,这不是很实用。)

所以,这个问题是专门询问是否有像 User.Following 这样的 bool,如果你被跟踪返回 true。

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

【问题讨论】:

标签: c# twitter linq-to-twitter


【解决方案1】:
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。

【讨论】:

    猜你喜欢
    • 2013-02-03
    • 2012-12-24
    • 2021-06-11
    • 1970-01-01
    • 1970-01-01
    • 2023-04-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多