July 05, 2011 - 4 comments

Pull your latest tweet with PHP

Found some better code to pull your latest tweet:

<?php
	$username='thatbradleyguy'; // set user name
	$format='json'; // set format
	$tweet=json_decode(file_get_contents("http://api.twitter.com/1/statuses/user_timeline/{$username}.{$format}")); // get tweets and decode them into a variable
	echo $tweet[0]->text; // show latest tweet
?>

Published by: Bradley in Uncategorized

Comments

Vezu
July 11, 2011 at 4:48 am

Nice one. Thanks. How to i include the RT?

    Bradley
    July 11, 2011 at 5:23 am

    This code will show you retweeting others if the retweet is a quote retweet.

Leave a Reply