I have a simple application that loads the last 20 tweets from a given user.
The request is for xml.
Everything works fine when I test on my local server, but once I upload it to the site (WordPress), 50% of the time it works and 50% it doesn’t and I get the “NetworkError: 500 Internal Server Error.”
This is the part of the request that faces the problem:
$xmldata = 'http://twitter.com/statuses/user_timeline/' . $user_name . '.xml';
$open = fopen($xmldata, 'r');
$content = stream_get_contents($open);
fclose($open);
$xml = new SimpleXMLElement($content);
The error log file says:
PHP Fatal error: Uncaught exception ‘Exception’ with message ‘String could not be parsed as XML’
There is obviously nothing wrong with the code if it is actually working some of the time, or else it wouldn’t work at all.
Any ideas on what’s causing this error?
Is this a problem with the xml response from twitter?
Thank you.