0

I'm working on a project that parses tweets and saves them to a db. I'd also like to create a local, front end interface that will live update when the tweet comes in (no page reloads etc.) I'm using the basic AJAX/PHP polling model seen here. But what I need is:

When a tweet comes in and is parsed, for performance reasons, I'd like to write it to a .txt file, possibly just their name, handle, and the tweet. I'd like to write it in a JSON format. And I'd need php to monitor that file and pull the last entry every time a new one is appended to the text file. Is this the right way to go about it? and has anyone done this before? Thanks!

G.Thompson
  • 807
  • 2
  • 11
  • 25
  • Have a look at node.js it thrives when you need to keep a constant connection. http://nodejs.org/ – 1321941 Aug 13 '12 at 17:06
  • The technique you're referring to is known as Document-oriented storage...there are DB management systems out there that work directly under this scope, and use JSON style formatting. [You should have a look at MongoDB](http://www.mongodb.org/display/DOCS/Schema+Design) with [Node.js](http://nodejs.org/) – Ohgodwhy Aug 13 '12 at 17:07
  • node.js was my original idea and I will use it in the future but for familiarity and timeline I need something I'm familiar working with. – G.Thompson Aug 13 '12 at 17:07
  • Short of using an actually alternate to mysql(mongodb) is there any easy way just to append new lines and check for changes? – G.Thompson Aug 13 '12 at 17:12
  • You should use MySQL to store the tweets. It's the best way to handle it! – Elastic Lamb Aug 13 '12 at 17:07

1 Answers1

0

The best way to do this would be a push model, as suggested. Node.js has made this alot simpler by just including socket.io and emitting the message, letting socket.io do the complex stuff (it does websockets as a first choice and last pick is the polling model you looked at, all depending on browser support). Just fetch the tweets, store it in the database and at the same time send it to your node application that will in turn emit it to all subscribers.

Clarence
  • 2,944
  • 18
  • 16