Skip to main content

Showing your last tweet using PHP

·68 words·1 min

While editing my blog theme, I decided to add my last thoughts in twitter to the website. Came with a very simple php code that will get the information from the last twitter post and show it as a text line, so you can add in anywhere you want.

This is the code:

<?php
preg_match('#<text>(.*)#',file_get_contents('http://twitter.com/statuses/user_timeline/username.xml?count=1'), $matches);
echo $matches[0]
?>

Of course, remember to change username for your own.