semifor / net-twitter-lite

A lighter weight (non-Moose) Perl interface to the Twitter API
Other
26 stars 11 forks source link

200: OK #23

Closed Melchester closed 7 years ago

Melchester commented 7 years ago

My perl programs have suddenly started returning 200: OK and no data is included. This does not happen all the time. If we repeat the request several times it will eventually work. It does not seem to associated with any Twitter limits.

semifor commented 7 years ago

Ah, yes! My favorite Twitter API error.

This seems to happen when Twitter makes an error on their end. They must rotate in systems that aren't configured and ready to serve the API, or they misroute API requests to the web app. In any case, Net::Twitter::Lite makes an API call expecting JSON, get's a successful HTTP response, but the response does NOT have a JSON body.

You can set wrap_result => 1 in the constructor (see the docs), to get access to the full HTTP response. Dump that to your logs or a file to see exactly what Twitter is returning. Share the result if/when you see it again. I'm curious to see what you get.

In any case, this isn't a bug in Net::Twitter::Lite. It's fortunately not something I see often, now, but does still occur and is entirely on Twitter's end.

Also, please have a look at Twitter::API. It is the successor to Net::Twitter and Net::Twitter::Lite. It's not quite as light weight as Net::Twitter::Lite, but it sheds a lot backwards compatibility cruft required for prior versions on the Twitter API and gives me a single perl5 library to maintain for Twitter API access going forward. Feedback welcome.

Melchester commented 7 years ago

Okay, thanks. I did (previously) check out the response and could not see anything that would indicate a problem. Re Twitter::API ... when you say "The interface may change." does that mean if we start using it, it may suddenly stop working without any notification?