问题描述
我的应用程序中有一个查找用户关注者ID的功能.但是我想获取这些关注者的screenName.
I have a function in my application that find IDs of a user followers.But I want to get the screenName of these followers.
我试图直接获取followers.screenName,但是它不起作用,因为关注者的类型是SocialGraph而不是字符串!我尝试将其转换为字符串,但无法执行,因为它返回了一个列表.
I tried to get directly followers.screenName but it doesn't work because followers type is SocialGraph and not string!I tried to convert this on string but I can't because it returns a list.
例如,当我搜索拥有1680个关注者的人时,就会引起问题.它给我一个错误:超出了速率限制.
It cause problems for example when I search someone who has 1680 followers.It gives me the error : The rate limit is exceeded.
我想知道是否可以对一组用户ID进行相同的操作而不会超出API的速率限制?我正在使用lintotwitter ...
I want to know if it is possible to do the same thing with a group of userID to not exceed the rate limits of the API? I am working with lintotwitter...
我该怎么办?
我的代码如下:
public List<string> RecupererFollower()
{
List<string> idFollowers=new List<string>();
var followers =
(from follower in MainPage.twitterCtxProp.SocialGraph
where follower.Type == SocialGraphType.Followers &&
follower.ScreenName == MainPage.texte
select follower)
.ToList();
idFollowers = followers[0].IDs;
return idFollowers;
}
public List<User> GetScreenName()
{
List<string>idFollowers=RecupererFollower();
int nbfollower = idFollowers.Count();
List<User> listeFollowers = new List<User>();
for (int i = 0; i < nbfollower; i++)
{
var usersResponse =
(from user in MainPage.twitterCtxProp.User
where user.Type == UserType.Lookup &&
user.UserID == idFollowers[i]
select user).SingleOrDefault();
Users = new User //Un utilisateur est créé grâce aux données récupérées précédemment.
{
Name = usersResponse.ScreenName,
Text = usersResponse.Status.Text,
ImageUrl = usersResponse.ProfileImageUrl,
Bio = usersResponse.Description,
Url = usersResponse.Url,
NbFollowers = usersResponse.FollowersCount,
NbFavorite = usersResponse.FavoritesCount,
NbStatus = usersResponse.StatusesCount,
NbFollowing = usersResponse.FriendsCount,
NbListe = usersResponse.ListedCount,
Timezone = usersResponse.TimeZone,
Location = usersResponse.Location,
};
listeFollowers.Add(Users);
}
return listeFollowers;
}
推荐答案
Twitter API正在设置速率限制.限制是在时间窗口内一定数量的请求.时间窗口通常为15分钟.对于Lookup,速率限制为180.您可以使用HelpType.RateLimits查询: http ://linqtotwitter.codeplex.com/wikipage?title =获取%20Rate%20Limits -这将使您编写代码来确定速率限制.然后,您可以最大化速率限制,然后等到下一个窗口继续.
The Twitter API is setting rate limits. The limit is a certain number of requests during a time window. The time window is typically 15 minutes. For Lookup, the rate limit is 180. You can use a HelpType.RateLimits query: http://linqtotwitter.codeplex.com/wikipage?title=Getting%20Rate%20Limits - this will let you write code to figure out what a rate limit is. Then, you can max out your rate limit and wait until the next window to continue.
这篇关于由于API速率限制,无法获取用户ID列表的screenName.我能做些什么? linqtotwitter C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!