define('DB_NAME', 'dbname'); // The name of the database
define('DB_USER', 'dbuser'); // Your MySQL username
define('DB_PASSWORD', 'agoodpassword'); // ...and password
define('DB_HOST', 'localhost'); // 99% chance you won't need to change this value
//connect to the database
$mysqli = new mysqli(DB_HOST,DB_USER,DB_PASSWORD,DB_NAME);
//retrieve a twitter feed
$jsonFeed = file_get_contents('https://api.twitter.com/1/statuses/user_timeline.json?include_entities=true&include_rts=true&screen_name=craigmayhew&count=200');
$json = json_decode($jsonFeed);
//input each of the tweets into a database table
foreach($json as $js){
$mysqli->query('INSERT IGNORE INTO tweets (time,text) VALUES (\''.$mysqli->real_escape_string(date('Y-m-d H:i:s',strtotime($js->created_at))).'\',\''.$mysqli->real_escape_string($js->text).'\')');
}
?>