Hey Colin, You want to make sure you are using CURL to read from the API otherwise you loose all the header information we return. That being said, in your example the stack trace error will be thrown if we return an error. This is because you haven't checked that:
$buffer !== FALSE; If there is an error your $buffer variable will be false which SimpleXMLElement cannot open. You can quickly check this on the command line using: curl -D - http://api.twitter.com/1/statuses/user_timeline/britishabroad.xml (the -D - means include headers in the output) You may find it easier to interact with the Twitter API through one of our community written libraries. http://dev.twitter.com/pages/libraries Hope that helps, Matt On Wed, Jul 7, 2010 at 2:42 AM, [email protected] < [email protected]> wrote: > $twitter_url = "http://api.twitter.com/1/statuses/user_timeline/ > britishabroad.xml"; > > $buffer = file_get_contents($twitter_url); > $xml = new SimpleXMLElement($buffer); > > $status_item = $xml -> status; > $status = $status_item -> text; > > echo $status; > > I am getting an error: > > Fatal error: Uncaught exception 'Exception' with message 'String could > not be parsed as XML' in /home/bhammers/demophon/dashboard/test.php:5 > Stack trace: #0 /home/bhammers/demophon/dashboard/test.php(5): > SimpleXMLElement->__construct('') #1 {main} thrown in /home/bhammers/ > demophon/dashboard/test.php on line 5 > > > Would appreciate any help. > > Thanks > > Colin > -- Matt Harris Developer Advocate, Twitter http://twitter.com/themattharris
