Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Utilizing Twitter's Streaming API w/ jQuery?

Twitter's Streaming API seems to provide a way to receive realtime tweets without constantly polling for new data. Would it be possible to make use of this API using jQuery (or maybe falling back to pure JS)?

As far as I can tell, there's no built-in way for jQuery to stream an HTTP request with JSON. Is that correct, or did I miss something? If this ability isn't built-in, has anyone already tackled this problem with a plugin or example?

Update: From what I can gather, HTML 5's support for WebSockets would likely be the best approach to achieve this. Unfortunately that means mainstream compatibility is still at least a few years out. As far as I know, these browser versions currently support WebSockets in some fashion:

  • WebKit 5 (Safari/Chrome)
  • Firefox 4
  • IE9 (Eventually)
like image 700
Wilco Avatar asked Jul 22 '10 19:07

Wilco


1 Answers

HTML5 WebSockets would probably be the best choice.

It is possible to use WebSockets for modern browsers and Flash fallback for unsupported browsers.

This one supports alle browsers: http://jwebsocket.org/index.htm?page=browsers.htm

You can also try this on, but not tested on IE6: http://github.com/gimite/web-socket-js

like image 167
Sindre Sorhus Avatar answered Oct 16 '22 19:10

Sindre Sorhus