Twitter api - no more than 150 requests per hour
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 wor开发者_运维技巧karound - 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
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.
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.
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.
精彩评论