to clarify you know when your on twitter and you get an update telling you have 2 new tweets, i got the ajax referesh page bit sorted but how do i catch the new update and count them!! if i make sense sorry!!
help will be appreciated
cheers!
kindest regards
Solomon saleh
The way twitter do it is basically:
One way of catching how many updates there are is to keep track of the last tweet id shown on the user’s page (each tweet has a unique id). So, when the page is loaded, the max(tweet id) is, say, 100. Your ajax call to check for updates will be something like:
The
check_updates.phpscript then basically checks the DB for latest tweets for the logged in user where id > 100. Similarly, when the user clicks “Show tweets”, the url called will be something along the lines of:This will mean that
show_updates.phponly returns tweets that haven’t been seen before, keeping response times to a minimum.The examples above send the id of the last tweet back to the server for comparison, but it could equally be done via the current timestamp. The server-side calculations would essentially be the same (look for tweets since time: X rather than tweet id: y) but it has the benefit of the client side not having to keep track of the last tweet id loaded.