[twitter-dev] Re: Failed API returning over capacity HTML page content

2009-07-15 Thread Nick Arnett
On Wed, Jul 15, 2009 at 8:03 AM, J.D. jeremy.d.mul...@gmail.com wrote:


 This is really a pain because I'm calling the API and expecting JSON
 data back. Do I need to check the data each time and see if I actually
 got html by mistake? If so, then I'm uncertain what I should do with
 the html.


In my experience, that's necessary anyway - I wouldn't trust that it would
never happen.  My code waits a few seconds and tries again if the JSON parse
fails.  A bunch of fails in a row and it gives up.

Nick


[twitter-dev] Re: Failed API returning over capacity HTML page content

2009-07-15 Thread J.D.

On Jul 15, 9:09 am, Nick Arnett nick.arn...@gmail.com wrote:
 My code waits a few seconds and tries again if the JSON parse
 fails.  A bunch of fails in a row and it gives up.

Thanks. I have similar code around the web calls, but had not put it
around the json parse yet.



[twitter-dev] Re: Failed API returning over capacity HTML page content

2009-07-15 Thread Alex Payne
JD,
Whether talking to the Twitter API or any other API on the web, always check
the response code before attempting to do any processing of the response
body. Proceed only if you got a 200 (or the response code you expected for
that particular operation). Many things can go wrong in the process of
making an HTTP request between your computer and our servers.

On Wed, Jul 15, 2009 at 10:32, J.D. jeremy.d.mul...@gmail.com wrote:


 On Jul 15, 9:09 am, Nick Arnett nick.arn...@gmail.com wrote:
  My code waits a few seconds and tries again if the JSON parse
  fails.  A bunch of fails in a row and it gives up.

 Thanks. I have similar code around the web calls, but had not put it
 around the json parse yet.




-- 
Alex Payne - Platform Lead, Twitter, Inc.
http://twitter.com/al3x


[twitter-dev] Re: Failed API returning over capacity HTML page content

2009-07-15 Thread J.D.

 Whether talking to the Twitter API or any other API on the web, always check
 the response code before attempting to do any processing of the response
 body. Proceed only if you got a 200 (or the response code you expected for
 that particular operation). Many things can go wrong in the process of
 making an HTTP request between your computer and our servers.

I'm fairly certain I did get a 200, but I got html instead of the json
I requested.