So I made this post due the twitters infamous changes that screwed up my last script that pulled your last tweet via atom protocol…
Anyways I can’t take full credit for the script since part of it I got from Bradley Spencer, I simply added the formatting functionality after the tweet extraction which he did not provide on his blog ;)
[cc lang=”php”]
// set user name
$username=’websymantecs’;
// set format
$format=’json’;
//get tweets and decode them into a variable
$tweet=json_decode(file_get_contents(“http://api.twitter.com/1/statuses/user_timeline/{$username}.{$format}”));
//now lets take this variable/string and manipulate it to display it formatted correctly…
$link = strstr($tweet[0]->text, “http”);
$text = substr($tweet[0]->text, 0, strpos($tweet[0]->text, “http”));
echo $text . ‘‘.$link.’‘;
[/cc]