Tweet me!
| 26 July 2010
It is a very simple and easy way of going about doing this. I have set up a demo for you, you can basically copy and paste it into your code and it will work! I have added a print_r() function at the end to print the whole xml file
<?php
//SET USERNAME TO BE THE USER YOU WANT THE RSS DATA FROM
$username = 'calebnance';
$rssurl = "http://twitter.com/statuses/user_timeline/".$username.".xml";
$ch = curl_init();
$timeout = 5;
curl_setopt($ch, CURLOPT_URL,$rssurl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT,$timeout);
$result = curl_exec($ch);
curl_close($ch);
$xml = simplexml_load_string($result);
print_r($xml);
?>
Then you get this:
SimpleXMLElement Object ( [@attributes] => Array ( [type] => array ) [status] => Array ( [0] => SimpleXMLElement Object ( [created_at] => Mon Jul 26 16:59:09 +0000 2010 [id] => 19587878034 [text] => @nochristindont aha thanks. Workin hard on it. :0 [source] => Twitter for Android [truncated] => false [in_reply_to_status_id] => 19542749106 [in_reply_to_user_id] => 44201416 [favorited] => false [in_reply_to_screen_name] => nochristindont [user] => SimpleXMLElement Object ( [id] => 34630993 [name] => Caleb Nance [screen_name] => calebnance [location] => North Carolina [description] => Help with Joomla, through my site and my tutorials on YouTube. Then about anything else I feel like posting. [profile_image_url] => http://a2.twimg.com/profile_images/1087258806/profile_normal.jpg [url] => http://Calebnance.com
This is a very small part of what will come out of an active twitter feed, here are a coupld examples to try and narrow the print down, instead of printing the whole return value.
<?php
print_r($xml->status[0]->user->name);
?>
Which returns this, SimpleXMLElement Object ( [0] => Caleb Nance )
Good luck, and I hope this helps!



