如果我调用 Twitter API 来获取我所有的关注者,那么对 API 的调用次数是多少? [英] If I call Twitter API to get all of my followers, how many calls to the API is that?

查看:24
本文介绍了如果我调用 Twitter API 来获取我所有的关注者,那么对 API 的调用次数是多少?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我想通过调用 twitter API 下载我所有关注者的列表,调用次数是多少?是一个电话还是我的粉丝数量?

If I want to download a list of all of my followers by calling the twitter API, how many calls is it? Is it one call or is it the number of followers I have?

谢谢!

斯里拉姆

推荐答案

如果您只需要关注者的 ID,您可以指定:

If you just need the IDs of your followers, you can specify:

http://api.twitter.com/1/followers/ids.json?screen_name=yourScreenName&cursor=-1

此调用的文档位于此处.此调用每次调用最多可返回 5,000 个关注者 ID,您必须跟踪每次调用的 cursor 值.如果您的关注者少于 5,000,则可以省略 cursor 参数.

The documentation for this call is here. This call will return up to 5,000 follower IDs per call, and you'll have to keep track of the cursor value on each call. If you have less than 5,000 followers, you can omit the cursor parameter.

但是,如果您需要获取所有关注者的完整详细信息,则需要进行一些额外的 API 调用.

If, however, you need to get the full details for all your followers, you will need to make some additional API calls.

我建议使用 statuses/followers 来获取关注者个人资料,因为您每次 API 调用最多可以请求 100 个个人资料.

I recommend using statuses/followers to fetch the follower profiles since you can request up to 100 profiles per API call.

使用statuses/followers时,您只需指定您希望获取哪些用户的关注者即可.结果按照关注者关注指定用户的顺序返回.此方法不需要身份验证,但它确实使用了游标,因此您需要为每次调用管理游标 ID.举个例子:

When using statuses/followers, you just specify which user's followers you wish to fetch. The results are returned in the order that the followers followed the specified user. This method does not require authentication, however it does use a cursor, so you'll need manage the cursor ID for each call. Here's an example:

http://api.twitter.com/1/statuses/followers.json?screen_name=yourScreenName&cursor=-1

或者,您可以使用 users/lookup 通过指定以逗号分隔的用户 ID 列表来获取关注者配置文件.您必须进行身份验证才能发出此请求,但是您可以获取任何您想要的用户配置文件——而不仅仅是那些关注指定用户的用户配置文件.一个示例调用是:

Alternatively, you can user users/lookup to fetch the follower profiles by specifying a comma-separated list of user IDs. You must authenticate in order to make this request, but you can fetch any user profiles you want -- not just those that are following the specified user. An example call would be:

http://api.twitter.com/1/users/lookup.json?user_id=123123,5235235,456243,4534563

因此,如果您有 2,000 个关注者,您只需一次调用即可通过 followers/ids 获取所有关注者 ID,如果这就是您所需要的.如果您需要完整的配置文件,您将使用 statuses/followers 进行 20 次调用,而在另外使用 users/lookup 时,您将使用 21 次调用,因为对 em>followers/ids 获取 ID 所必需的.

So, if you had 2,000 followers, you would use just one call to obtain all of your follower IDs via followers/ids, if that was all you needed. If you needed the full profiles, you would burn 20 calls using statuses/followers, and you would use 21 calls when alternatively using users/lookup due to the additional call to followers/ids necessary to fetch the IDs.

请注意,对于所有 Twitter API 调用,我建议使用 JSON,因为它是一种比 XML 轻得多的文档格式.您通常只会通过网络传输大约 1/3 到 1/2 的数据,而且我发现(根据我的经验)在提供 JSON 时,Twitter 超时的频率较低.

这篇关于如果我调用 Twitter API 来获取我所有的关注者,那么对 API 的调用次数是多少?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆