Problems parsing lookup.xml with @simplexml_load_file()


#1

All was fine until a time ago… I cannot parse http://api.twitter.com/1/users/lookup.xml?screen_name= with the @simplexml_load_file() PHP… any suggestion… would be apreciated… thanks.


#2

here is my code:

$url = “http://api.twitter.com/1/users/lookup.xml?screen_name={$name}”;

if (@simplexml_load_file($url))
{
$xml = simplexml_load_file($url);
$id = $xml->user->id;
$av = $xml->user->profile_image_url;
}


#3

Have you tried any debugging or error handling around this? What’s the actual API response you’re getting?


#4

result: runtime error time: 0.02s

<?php $url = "http://api.twitter.com/1/users/lookup.xml?screen_name=disney"; if (@simplexml_load_file($url)) { $xml = simplexml_load_file($url); $id = $xml->user->id; $av = $xml->user->profile_image_url; } echo $id; ?>

#5

Just runtime error


#6

There’s a lot more you can try to debug through this. Try working outside of your programming language and making this request on the command line using a tool like curl. Consider using a more robust XML parser in PHP. Consider making the API request with a full featured HTTP library instead of simplexmlLoad_file…


#7

Can any one tell me what are the applicable arguments that we can pass in simplexml_load_file using php


#8