Jump to content

[SOLVED] SimpleXML catching 404


sprinkles

Recommended Posts

I'm building a script with the last.fm datafeeds.

 

When a incorrect username is given to the script, the last fm site throws a 404, and results in this PHP error:

 

Warning: simplexml_load_file(http://ws.audioscrobbler.com/1.0/user/RichardJohn/tasteometer.xml?with=) [function.simplexml-load-file]: failed to open stream: HTTP request failed! HTTP/1.0 404 Not Found in /home/richardm/public_html/lastfmcompatibility.php on line 12

Warning: simplexml_load_file() [function.simplexml-load-file]: I/O warning : failed to load external entity "http://ws.audioscrobbler.com/1.0/user/RichardJohn/tasteometer.xml?with=" in /home/richardm/public_html/lastfmcompatibility.php on line 12
There was a problem loading the data feed.

 

Is there a way to catch this error and just present a friendly error?

Link to comment
https://forums.phpfreaks.com/topic/54008-solved-simplexml-catching-404/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.