Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Twitter + HTML5 webSocket API

Is there a way of connecting to Twitter through the HTML5 webSocket API (JavaScript)?

Currently http://streamie.org/ seems to be doing something like that but they are leading it through http://local.streamie.org:8888/ so it looks like they are running the websocket.

The JavaScript part is quite clear:

websocket = new WebSocket('ws://echo.websocket.org/');


websocket.onopen = function(event) {

    websocket.send('hello from client');

    console.log('CONNECTED');
};

websocket.onclose = function(event) {

    console.log('DISCONNECTED');
};

websocket.onmessage = function(event) {

    console.log(event.data);
};

websocket.onerror = function(event) {


};

But what's the websocket address for Twitter?

like image 979
DADU Avatar asked Mar 15 '11 15:03

DADU


2 Answers

Twitter does not provide a WebSocket interface. You will have to run a proxy on your own server if you want to access the Twitter Streaming API through WebSockets.

like image 194
abraham Avatar answered Sep 18 '22 22:09

abraham


Here is a demo site showing the use of WebSockets and a Twitter feed - http://kaazing.me. You can also download our websocket gateway from here - https://kaazing.com/download/ - which also supports older browsers e.g. you can use the WebSocket APIs with older browsers.

But as Abraham said, you still need to build your own proxy to Twitter since they do not provide a WS interface.

like image 28
Jonas Avatar answered Sep 19 '22 22:09

Jonas