// http://frankkoehl.com/2009/08/archive-entire-twitter-timeline/ /** * INSTALLATION * execute $sql on your DB to get the latest twitter post * set the value of `id` to a variable named $since_id * set $since_id to false if the table is empty (i.e. a new install) **/ $con = mysql_connect('localhost', 'mysql_user', 'mysql_password'); if (!$con) { die('Could not connect to localhost: ' . mysql_error()); } $db_selected = mysql_select_db('dbname', $con); if (!$db_selected) { die ('Can\'t use dbname : ' . mysql_error()); } // table in dbname is here named twitter $query = sprintf("SELECT `id` FROM `twitter` ORDER BY `id` DESC LIMIT 1"); $result = mysql_query($query); if (!$result) { $message = 'Invalid query: ' . mysql_error() . "\n"; $message .= 'Whole query: ' . $query; die($message); } while ($row = mysql_fetch_assoc($result)) { $since_id = $row['id']; } if ( ! isset($since_id) ) { die('No id to be had - check table. ' . mysql_error()); } /** End INSTALLATION **/