Reputation: 1
I use following code to follow user:
TwitterService ts = new TwitterService(TWI_CONSUMER_KEY, TWI_CONSUMER_SECRET);
ts.AuthenticateWith(token.Token, token.Secret);
var users = ts.SearchForUser(query); //Get list of users by query
//...
foreach (var user in users)
{
var u = ts.FollowUser(user.Id); //Follow user
}
and get exception:
System.ArgumentException: Item with the same key has already been added
Are there any mistakes? Please help me.
Upvotes: 0
Views: 1583
Reputation: 4330
The exception is being thrown as the user your adding, you're already following. You'll need to either:
var u.ts.FollowerUser(..)
in a try/catch so the loop will continueUpvotes: 1