问题
How can I find all the followers a Twitter user has using Linq2Twitter?
All I can find in the documentation is a reference to the .Following property, not the .Followers property.
var result = from search in context.List
where search.Following //etc
How can I find the followers a Twitter user has if I provide the twitter username?
twitter.com/foobar // 'foobar' is the username.
回答1:
LINQ to Twitter lets you query the social graph for friends and followers. Here's an example of how to get followers:
var followers =
(from follower in twitterCtx.SocialGraph
where follower.Type == SocialGraphType.Followers &&
follower.ID == "15411837"
select follower)
.SingleOrDefault();
followers.IDs.ForEach(id => Console.WriteLine("Follower ID: " + id));
That will return IDs. Here's the full documentation: http://linqtotwitter.codeplex.com/wikipage?title=Listing%20Followers&referringTitle=Listing%20Social%20Graphs.
Joe
回答2:
The Twitter API is GET followers/ids so I have to guess that the Linq2Twitter code is probably something like the following:
var users = from tweet in twitterCtx.User
where tweet.Type == UserType.Show &&
tweet.ScreenName == "Sergio"
select tweet;
var user = users.SingleOrDefault();
var followers = user.Followers;
回答3:
The following code demonstrates how to get all followers of a particular user
var followers =
await
(from follower in twitterCtx.Friendship
where follower.Type == FriendshipType.FollowerIDs &&
follower.UserID == "15411837"
select follower)
.SingleOrDefaultAsync();
if (followers != null &&
followers.IDInfo != null &&
followers.IDInfo.IDs != null)
{
followers.IDInfo.IDs.ForEach(id =>
Console.WriteLine("Follower ID: " + id));
}
Source: Linq2Twitter Github
Note: This method call is limited to 5000 followers only. If you just need the count of followers, it might be better to scrape it off the twitter website
来源:https://stackoverflow.com/questions/10724064/find-all-followers-for-a-user-using-linq-to-twitter