Skip to content

Friendships

linvi edited this page Jun 6, 2015 · 11 revisions

Overview

From a user account perspective another user can either be a follower or a person that you you follow also described as friend.

Get Followers

Rate Limit Considerations It is important to understand that due to Twitter REST API limits, you will have to consider using the RateLimit class to get all the followers of a famous person.

Get SOME of the followers

var user = User.GetUserFromScreenName("<user_screen_name>");

// Get the first 250 followers of the user
var followers = User.GetFollowers(<user_identifier>);
var followers = user.GetFollowers();

// Get the first 5000 followers' ids of the user
var followerIds = User.GetFollowerIds(<user_identifier>);
var followerIds = user.GetFollowerIds();

Get ALL the followers

Please note that retrieving all the followers of a user might take a LOT of time. Please consider using Threads or Async Tasks.

Track And Await : "Gonna catch them all..."

The first and easiest way to get all the followers of a specific member is to use the TrackAndAwait option of the RateLimit awaiter.

// Tweetinvi will now wait for tokens to be available before performing a request.
RateLimit.RateLimitTrackerOption = RateLimitTrackerOptions.TrackAndAwait;

// Get ALL the followers' ids of a specific user
var followerIds = User.GetFollowerIds(<user_identifier>, Int32.MaxValue);
var followerIds = user.GetFollowerIds(Int32.MaxValue);

Twitter Accessor : "Divide to conquer!"

This solution is more complex as it has not yet been implemented in Tweetinvi. We will need to use the appropriate tools to execute a cursor Custom Queries.

Get All Followers Code

Get Friends

Rate Limit Considerations It is important to understand that due to Twitter REST API limits, you will have to consider using the RateLimit class to get all the friends of a famous person.

Get SOME of the friends

var user = User.GetUserFromScreenName("<user_screen_name>");

// Get the first 250 friends of the user
var friends = User.GetFriends(<user_identifier>);
var friends = user.GetFriends();

// Get the first 5000 friends' ids of the user
var friendIds = User.GetFriendIds(<user_identifier>);
var friendIds = user.GetFriendIds();

Get ALL the friends

Please note that retrieving all the friends of a user might take a LOT of time. Please consider using Threads or Async Tasks.

Track And Await : "Gonna catch them all..."

The first and easiest way to get all the friends of a specific member is to use the TrackAndAwait option of the RateLimit awaiter.

// Tweetinvi will now wait for tokens to be available before performing a request.
RateLimit.RateLimitTrackerOption = RateLimitTrackerOptions.TrackAndAwait;

// Get ALL the friends' ids of a specific user
var friendsIds = User.GetFriendIds(<user_identifier>, Int32.MaxValue);
var friendsIds = user.GetFriendIds(Int32.MaxValue);

Twitter Accessor : "Divide to conquer!"

This solution is more complex as it has not yet been implemented in Tweetinvi. We will need to use the appropriate tools to execute a cursor Custom Queries.

Get All Friends Code

Get Relationship between Users

To get the relationship details between 2 members you can use the following code.

var relationshipDetails = Friendship.GetRelationshipDetailsBetween(<user_identifier_1>, <user_identifier_2>);
Clone this wiki locally