1

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.
Only Bolivian Here
  • 35,719
  • 63
  • 161
  • 257

3 Answers3

2

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

Joe Mayo
  • 7,501
  • 7
  • 41
  • 60
0

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;
Mike Atlas
  • 8,193
  • 4
  • 46
  • 62
0

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

Salman Hasrat Khan
  • 1,971
  • 1
  • 20
  • 27