How to follow a user using the TweetSharp API

875 Views Asked by At

I'm using the TweetSharp API, and I need to follow people in a C# List, however, I'm having trouble. The appropriate code is as follows:

var results = service.Search(new SearchOptions {Q = hashtag}); //hashtag string entered by user
List<decimal> users = new List<decimal>();

foreach (var tweet in results.Statuses)
{
    users.Add(tweet.User.Id);
}

foreach (decimal user in users)
{
    service.FollowUser(user);  //follow each user, the issue is here. 
}

Apparently I am using invalid arguments.

1

There are 1 best solutions below

0
On

The FollowUser method takes a FollowUserOptions type as an argument, not a decimal. Try this:

foreach (var user in users)
{
    var options = new FollowUserOptions
    {
        UserId = user
    };

    service.FollowUser(options);
}