Get user Followers

Oct 20, 2014 at 5:18 AM
Hello ,

i tried to use many various examples to get a user followers but i keep get null, am i missing something ?
this is what i tried to user

1.
int maxObjectsToRetrieve = 7500;
                var userId = 14230524;
                var followerQuery = String.Format("https://api.twitter.com/1.1/followers/ids.json?screen_name={0}", "ladygaga");
                var resultSet = TwitterAccessor.ExecuteCursorGETQuery<IIdsCursorQueryResultDTO>(followerQuery, maxObjectsToRetrieve, 1461847482652938527);
               
var ladygaga =Tweetinvi.User.GetUserFromScreenName("ladygaga");
               IEnumerable<IUser> followers = ladygaga.GetFollowers(2000);
                int x = followers.Count();
3.
user = Tweetinvi.User.GetUserFromScreenName("ladygaga");
                List<IUser> x = user.Followers;
Thanks
Coordinator
Oct 20, 2014 at 11:41 PM
Have you specified your credentials before performing these requests?
The TwitterCredentials needs to be set in order to use Tweetinvi.

Linvi
Oct 21, 2014 at 6:06 AM
Yea sure, this is the full code i use

 ILoggedUser loggedUser = null;

        IOAuthCredentials cred = TwitterCredentials.CreateCredentials
         ("XXXXXXXXXXXXXXXXXXXXXXXXXXX",
                     "XXXXXXXXXXXXXXXXX",
                     "XXXXXXXXXXXXXXXXX",
                     "XXXXXXXXXXXXXXXXXXXX");

        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnGetFollowers_Click(object sender, EventArgs e)
        {            
            TwitterCredentials.ExecuteOperationWithCredentials(cred, () =>
            {
                int maxObjectsToRetrieve = 7500;
                var userId = 14230524;
                var followerQuery = String.Format("https://api.twitter.com/1.1/followers/ids.json?screen_name={0}", "ladygaga");
                var resultSet = TwitterAccessor.ExecuteCursorGETQuery<IIdsCursorQueryResultDTO>(followerQuery, maxObjectsToRetrieve, 1461847482652938527);
                resultSet.ToString();
            });
        }
Coordinator
Oct 21, 2014 at 9:36 PM
Hi again,

Would you please check that your credentials are valid.
TwitterCredentials.SetCredentials("xxx", "xxx", "xxx", "xxx");
var loggedUser = User.GetLoggedUser();
var areCredentialsValid = loggedUser != null;
Then, if they are valid, your code should work. In fact this is working on my machine.
You just need to know that the request can take a while if you request lots of objects.

For example calling ladygaga.GetFollowers(2000); will make at least 21 requests which can take a while to execute.

Please give me some news concerning the problem.
Linvi
Oct 22, 2014 at 8:23 AM
Edited Oct 22, 2014 at 8:23 AM
Hello Linvi,
the user is logged

areCredentialsValid = true
Coordinator
Oct 22, 2014 at 10:54 AM
Ok thanks,

Do you get any result when doing the following query?
var ladygaga =Tweetinvi.User.GetUserFromScreenName("ladygaga");
// Followers without Maximum number of users
var followers = ladygaga.GetFollowers();
Linvi
Marked as answer by asoliman on 10/22/2014 at 4:34 AM
Oct 22, 2014 at 11:13 AM
Hey again,

yes this code is working

I got 250 user names
Oct 22, 2014 at 11:28 AM
The question,
250 is refere to what? is it a randomly 250 followers ?
if i want to pull all followers? what is the strategy to do that ?

Thanks for your time (Y)
Coordinator
Oct 22, 2014 at 1:33 PM
Edited Oct 22, 2014 at 1:34 PM
By performing a single query you can get up to 250 users using the Follower endpoint of Twitter.
By default Tweetinvi never does more than 1 operation. If you want more than 250, you can specify the number of users you want to get like you did.
var followers = ladygaga.GetFollowers(500);
But you need to take into consideration that when doing this you are going to perform 2 more queries.
This will result in your rate limits to get use way more quickly.

Consequently, in order to test, if Tweetinvi is working for you, please try with a limit to 500 followers.
If it does work you will need to ensure that you have enough queries left for the operation to complete.

Rate Limit Documentation
var followerRateLimit = rateLimit.FollowersIdsLimit;
var userLookup = rateLimit.UsersLookupLimit;
What I usually advise is that you use the UserIds from GetFollowerIds and retrieve the user detailed information when you need it.
var user = User.GetLoggedUser();
var followerIds = user.GetFollowerIds()
var first100FollowerIds = followerIds.Take(100);
var followers = User.GetUsersFromIds(first100Followers);
This give you more control over your rate limits.

Please note that I am currently working on a solution to allow developers to automatically rely on Tweetinvi for their RateLimit but this will only be available in the next version of Tweetinvi.

Hope this will help.
Linvi
Oct 22, 2014 at 1:52 PM
Hi again

This is a great idea to use
var user = User.GetLoggedUser();
var followerIds = user.GetFollowerIds()
var first100FollowerIds = followerIds.Take(100);
var followers = User.GetUsersFromIds(first100Followers);
But it's still have limitation right ?

it's max query is 5000 followers ?
Coordinator
Oct 22, 2014 at 3:40 PM
Hi,

No you can specify a number higher than 5000 to the user.GetFollowerIds(10000);
But as I said, be careful with your RateLimit when you request more than 5000 users, you will use your Tokens quite quickly.

Linvi
Marked as answer by asoliman on 10/22/2014 at 9:20 AM
Oct 22, 2014 at 4:21 PM
Thank you,
was clear enough (Y)