TweetSharp get the number of subscribers

Does anyone know how to use the TweetSharp function to count the number of account counters?

+3
source share
3 answers

You can count the number of friends and followers from the TwitterUser object. To directly select a user:

 var twitter = FluentTwitter.CreateRequest()
            .Users().ShowProfileFor("jimbob").AsJson();

 var response = twitter.Request();
 var user = response.AsUser();
 Console.Writeline( "jimbob has {0} followers", user.FollowersCount);

Custom objects are also returned with individual TwitterStatus objects (i.e. tweets), so you can get them directly from there and not make another call:

 var twitter = FluentTwitter.CreateRequest()
            .Statuses().OnHomeTimeline().AsJson();

 var response = twitter.Request();
 var tweets = response.AsTweets();
 foreach ( var tweet in tweets )
 {
     Console.Writeline( "Posted by {0}, who has {1} followers", tweet.User.ScreenName, tweet.User.FollowersCount);
 }
+2
source

I know this is old, but it works better for the new version than Nityan’s answer, since the Twitter API does not immediately return all of its subscribers.

, , .

const string consumerKey = "consumerKey";
const string consumerSecret = "consumerSecret";
const string accessToken = "accessToken";
const string accessTokenSecret = "accessTokenSecret";

string handleToSearchFor = "stackoverflow";

var service = new TwitterService(consumerKey, consumerSecret);
service.AuthenticateWith(accessToken, accessTokenSecret);

var users = service.SearchForUser(new SearchForUserOptions { Q = handleToSearchFor});
foreach (var user in users)
{
    Console.WriteLine("{0} has {1} followers and follows {2} people!", user.ScreenName, user.FollowersCount, user.FriendsCount);
}
+1
public void Method() {    
    IList<TwitterUser> twitterFollowers = null;
    ListFollowersOptions options = new ListFollowersOptions();

    options.ScreenName = screenName;
    twitterFollowers = service.ListFollowers(options);

    int followersCount = twitterFollowers.Count;
}
0

Source: https://habr.com/ru/post/1732508/


All Articles