Twitter api - 每小时不超过 150 个请求
我正在使用 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 ]
我在家里运行相同的代码 - 没问题。
很明显,在某些时候 Twitter 认为我们的工作全部来自一个直接 IP - 这就是为什么它达到了不应该的限制。
我是否有任何选择或解决方法 - 我可以使限制从我的直接机器 IP 计算 - 或到我的帐户而不是 IP?我可以使用代理吗?还有其他人遇到过这个问题并解决了吗?!
在有人要求该应用程序必须存在于我的工作中之前 - 它无法在其他任何地方运行!
干杯,
安迪
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:
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.
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?!
Before anyone asks the APP must live inside my work - it cannot run anywhere else!
Cheers,
Andy
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
针对帐户进行身份验证,以便您使用帐户的 API 请求限制,而不是未经身份验证的 IP 限制:
http://dev.twitter.com/pages/rate-limiting
http://dev .twitter.com/pages/auth
如果您仍然遇到问题,您可以要求将公司 IP 列入白名单,但对于您所说的内容(每小时只有几个请求),只需 auth'ing帐户是最好的选择。
Authenticate against an account so that you're using the account's API request limit, not the unauth'd IP limit:
http://dev.twitter.com/pages/rate-limiting
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.
您可以要求 Twitter 将限制提高到每小时 20000 个请求。这是一个非常简单的过程记录在他们的网站上。
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.
您还可以考虑使用他们的 streaming api ,它更好(实时)。它还会处理限制,因为只有新数据到达时您才会有请求。
You could also consider using their streaming api which is much better(realtime). It will also take care of the limit, because you will only have a request when new data arrives.