我在.NET 4.0 WinForms應用程序中使用TweetSharp v2.3.0。這裏是適合我的:
// this code assumes that your TwitterService is already properly authenticated
TwitterUser tuSelf = service.GetUserProfile(
new GetUserProfileOptions() { IncludeEntities = false, SkipStatus = false });
ListFollowersOptions options = new ListFollowersOptions();
options.UserId = tuSelf.Id;
options.ScreenName = tuSelf.ScreenName;
options.IncludeUserEntities = true;
options.SkipStatus = false;
options.Cursor = -1;
List<TwitterUser> lstFollowers = new List<TwitterUser>();
TwitterCursorList<TwitterUser> followers = service.ListFollowers(options);
// if the API call did not succeed
if (followers == null)
{
// handle the error
// see service.Response and/or service.Response.Error for details
}
else
{
while (followers.NextCursor != null)
{
//options.Cursor = followers.NextCursor;
//followers = m_twService.ListFollowers(options);
// if the API call did not succeed
if (followers == null)
{
// handle the error
// see service.Response and/or service.Response.Error for details
}
else
{
foreach (TwitterUser user in followers)
{
// do something with the user (I'm adding them to a List)
lstFollowers.Add(user);
}
}
// if there are more followers
if (followers.NextCursor != null &&
followers.NextCursor != 0)
{
// then advance the cursor and load the next page of results
options.Cursor = followers.NextCursor;
followers = service.ListFollowers(options);
}
// otherwise, we're done!
else
break;
}
}
注意:這可能被認爲是重複的問題。 (請參閱here和here。)但是,這些現有問題似乎與TweetSharp的不同(較舊版本)版本有關,因爲版本2.3.0中沒有TwitterService.ListFollowersOf()
方法。
謝謝..按預期工作..我注意到,使用v1.1 Twitter只允許你15請求/ 15分鐘..見這裏https://dev.twitter.com/docs/rate-limiting/1.1/限制,所以你可以得到的最大f鳥數量是15分鐘內的300): – hriziya 2013-06-29 09:55:20
@HiteshRiziya你可以使用[GET追隨者/ ids](https://dev.twitter.com/docs/api/1.1/get/followers/ids )與[GET用戶/查找](https://dev.twitter.com/docs/api/1.1/get/users/lookup)在15分鐘內獲得18000個關注者。 – 2013-07-10 19:19:25