Hi there, I'm afraid I can't help with the specifics of the prototypejs framework, but I don't see a GET line in your request headers. I can't imagine that prototypejs didn't send it, but a common cause of 400s in general is an invalid path in the GET line itself, so please post the full GET line here too (and see below for comments on access- control requests). A normal set of request headers for this request should look like this (and this request works for me, from browser):
(Request-Line) GET /statuses/public_timeline.json HTTP/1.1 Host twitter.com User-Agent Mozilla/5.0 (Windows; U; Windows NT 6.0; en-GB; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 (.NET CLR 3.5.30729) Accept text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language en-gb,en;q=0.5 Accept-Encoding gzip,deflate Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive 300 Connection keep-alive Furthermore - the access-control and origin headers in your request indicate that this was an access-control pre-request, not the actual GET. Can you maybe post the headers from the GET request itself? Or was it not sent? There is also a JS library listed on the twitter API wiki, and that has a public_timeline method if that's of any interest: http://sources.disruptive-innovations.com/twitterHelper/tags/latest/TwitterHelper.html#mozTocId519819 Alan On Aug 4, 10:30 pm, 0m4r <omar.adob...@gmail.com> wrote: > Hi All, > > I've been reading the API documentation and this support group as well > but I can't find an answer, or a solution, to my problem. > I've been writing some js code using the Twitter API but every time I > perform a call I got back the error in subject: HTTP 400 Bad Request > and no response at all. > > Here follows a pice of the code I am using (with the prototypejs > framework): > == > new Ajax.Request('http://twitter.com/statuses/public_timeline.json', { > method: 'GET', > encoding: 'UTF-8', > onLoading: function(){ > debug.update('Loading...'); > }, > onSuccess: function(transport) { > debug.update("SUCCESS: " + transport.responseJSON + "<br/>") > }, > onException: function(transport, exception){ > debug.update("EXCEPTION: " + exception); > }}); > > == > > here are the requests headers: > == > Host: twitter.com > > User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv: > 1.9.1.1) Gecko/20090715 Firefox/3.5.1 > > Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/ > *;q=0.8 > > Accept-Language: en-us,en;q=0.5 > > Accept-Encoding: gzip,deflate > > Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 > > Keep-Alive: 300 > > Connection: keep-alive > > Origin: null > > Access-Control-Request-Method: GET > > Access-Control-Request-Headers: x-prototype-version,x-requested-with > == > > and the response headers: > == > Date: Tue, 04 Aug 2009 20:20:48 GMT > > Server: hi > > Last-Modified: Tue, 04 Aug 2009 20:20:48 GMT > > Status: 400 Bad Request > > X-RateLimit-Limit: 150 > > X-RateLimit-Remaining: 135 > > Pragma: no-cache > > Cache-Control: no-cache, no-store, must-revalidate, pre-check=0, post- > check=0 > > Content-Type: application/json; charset=utf-8 > > X-RateLimit-Reset: 1249417836 > > Expires: Tue, 31 Mar 1981 05:00:00 GMT > > X-Revision: adb502e2c14207f6671fe028e3b31f3ef875fd88 > > X-Transaction: 1249417248-99305-1720 > > Set-Cookie: > _twitter_sess=BAh7CDoMY3NyZl9pZCIlN2NmZWIyZmU0NTQ3NjMyZGU1MThlNjZjODc0MGY2%250AODM6B2lkIiVlMzg5ZTViMmYzZjkwM2ExZDExMmRhMmM3NDFjNGMwOSIKZmxh > %250Ac2hJQzonQWN0aW9uQ29udHJvbGxlcjo6Rmxhc2g6OkZsYXNoSGFzaHsABjoK > %250AQHVzZWR7AA%253D%253D--5a76f810fb5fde72f43634d7423aff19f28b3aa7; > domain=.twitter.com; path=/ > > Vary: Accept-Encoding > > Content-Encoding: gzip > > Content-Length: 99 > > Connection: close > == > > Thanks to all for your help. > > 0m4r