使用 TweetSharp 关注用户
我使用以下代码来关注 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
}
并得到异常:
System.ArgumentException:已添加具有相同键的项目
是否有任何错误?请帮我。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当您添加的用户(您已经关注)时抛出异常。您需要:
var u.ts.FollowerUser(..)
包装在 try/catch 中,以便循环继续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 continue