javascript - Utilizing Twitter's Streaming API w jQuery? - Stack Overflow

Twitter's Streaming API seems to provide a way to receive realtime tweets without constantly polli

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 patibility 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)

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 patibility 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)
Share Improve this question edited Aug 4, 2010 at 16:50 Wilco asked Jul 22, 2010 at 19:27 WilcoWilco 33.4k49 gold badges132 silver badges161 bronze badges 3
  • This seems interesting, but at least for the Twitter streams you have to authenticate the request so wouldn't you be exposing your credentials by using JavaScript to get the stream? Otherwise, I think this JSON stream is a pretty cool idea and I'm going to look more into it. – Sandro Commented Jul 22, 2010 at 19:53
  • That's a good point that I hadn't discovered yet. In my particular case it wouldn't be a problem since I'm serving the page locally (and only accessible from localhost) and embedding it on my desktop. – Wilco Commented Jul 22, 2010 at 20:06
  • Do you have an example utilising the streaming api with websockets or jquery that you could share or provide some useful links that you used? – Sonoman Commented Jul 28, 2011 at 23:15
Add a ment  | 

2 Answers 2

Reset to default 4

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/index.htm?page=browsers.htm

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

This page might be of interest:

http://ajaxpatterns/HTTP_Streaming#Refactoring_Illustration

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744787781a4593732.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信