Live feed using AJAX / jQuery



I’m new to the Twitter API and after reading for a while the streaming API documentation I’m not sure if the following is possible:

I want to add a customized Twitter feed to a webpage. The feeds needs to be updated in real time with the feeds of a single account, so I think the best way is to use AJAX/jQuery.

Is this possible with the Streaming API. In the docs says that the clients needs to authenticate via oAuth, what would not work for the general public, but as said, I’m new to this and I’m not sure. If it’s possible could you give some advice where to start or so links to the related docs pages?




Generally this is possible, but won’t be that simple. If I were building it, I would have a single process connect to the filter.json streaming API (using credentials stored on the server), with the “follow” parameter set to the account I want to display Tweets for. Every Tweet sent over this stream would be written to some sort of datastore or database on my server.

Then in the frontend of the website, I would write Ajax code which would send a query every X seconds (depending on how “realtime” your system needs to be) with the timestamp of the last Tweet the code received. If the server would have any newer Tweets in its datastore, then they would be delivered as the response and the Ajax code would update it’s “last Tweet” timestamp.

Of course, the Twitter Timeline widget is much easier to implement and gives pretty much the same functionality: