Using the Twitter XML Feed in PHP

Parsing the Twitter XML feed for a user in PHP is now super simple.

$username = 'Kieran_Barnes';
$format = 'xml';
$tweet = simplexml_load_file("{$username}.{$format}");

$tweet is now an array of your latest tweets. Bonzer!

Displaying your latest tweet is easy too

<h4><a href="!/Kieran_Barnes" target="_blank"><?php echo $tweet->status[0]->text; ?></a></h4>
        <p>Posted <?php echo $tweet->status[0]->created_at ?> <span><a href="!/Kieran_Barnes" target="_blank">#Kieran_Barnes</a></span></p>

Author: Kieran Barnes

Kieran is a PHP developer with 15 years commercial experience. Specialist in WordPress, CakePHP, CubeCart and all things PHP.

Leave a Reply

Your email address will not be published. Required fields are marked *