java Twitter api - 每小时不超过 150 个请求
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2968476/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Twitter api - no more than 150 requests per hour
提问by RenegadeAndy
I am writing a twitter app using jtwitter - and its running inside a server inside my work. Anyway - whenever i run it from work it returns the error below and I am only making a couple requests per hour:
我正在使用 jtwitter 编写一个 twitter 应用程序 - 它在我工作的服务器内运行。无论如何 - 每当我从工作中运行它时,它都会返回以下错误,而且我每小时只发出几个请求:
HTTP/1.1 400 Bad Request
{"request":"/1/statuses/user_timeline.json?count=6&id=cicsdemo&","error":"Rate limit exceeded. Clients may not make more than 150 requests per hour."} ]
2010-06-03 18:44:49 zero.timer.TimerTask::run Thread-3
SEVERE [ CWPZA3100E: Exception during processing for timer task, "twitterTimer". Exception: java.lang.ClassCastException: winterwell.jtwitter.Twitter$Status incompatible with java.lang.String ]
I run the same code from home - its fine.
我在家里运行相同的代码 - 很好。
So obviously at some point twitter thinks our work is all coming from one direct IP - which is why its hitting a limit which it shouldnt.
所以很明显,在某些时候,twitter 认为我们的工作都来自一个直接的 IP——这就是为什么它达到了它不应该的限制。
Do I have any choice or workaround - can i make the limit be counted from my direct machine IP - or to my account instead of IP? Can i use a proxy? Has any body else had this problem and solved it?!
我有什么选择或解决方法 - 我可以让限制从我的直接机器 IP 中计算 - 或者我的帐户而不是 IP 吗?我可以使用代理吗?有没有其他人遇到过这个问题并解决了它?!
Before anyone asks the APP must live inside my work - it cannot run anywhere else!
在有人问 APP 必须存在于我的工作中之前 - 它不能在其他任何地方运行!
Cheers,
干杯,
Andy
安迪
回答by Amber
Authenticate against an account so that you're using the account's API request limit, not the unauth'd IP limit:
针对帐户进行身份验证,以便您使用帐户的 API 请求限制,而不是未授权的 IP 限制:
http://dev.twitter.com/pages/rate-limiting
http://dev.twitter.com/pages/rate-limiting
http://dev.twitter.com/pages/auth
http://dev.twitter.com/pages/auth
If you still have issues, you can ask for whitelisting of the company IP, but for what you're talking about (only a few requests an hour), just auth'ing to an account is the best option.
如果您仍然有问题,您可以要求将公司 IP 列入白名单,但对于您所谈论的(每小时只有几个请求),仅对帐户进行身份验证是最佳选择。
回答by Pablo Santa Cruz
You can ask Twitter to move up that limit up to 20000 requests per hour. It's a pretty straightforward process documented on their site.
回答by Alfred
You could also consider using their streaming apiwhich is much better(realtime). It will also take care of the limit, because you will only have a request when new data arrives.
您也可以考虑使用他们的流媒体 api,这要好得多(实时)。它还会处理限制,因为您只有在新数据到达时才会收到请求。

