使用PHP5读取XML文件[关闭]

So i've been trying to get some data from a PlaystationNetwork API,

http://www.psnapi.com.ar/ps3/api/psn.asmx/getPSNID?sPSNID=jameslfc19

So I've been using this code

<?php
//Get Username
$username = $_GET["u"];

// Passing the XML
$psnxml = @simplexml_load_file('http://psnapi.com.ar/ps3/api/psn.asmx/getPSNID?sPSNID=' .$username);

$psnname = $psnxml->PSNId->Avatar;
echo $psnname;
?>

This outputs absolutely nothing..

I'm using @ because otherwise I get a (Yes i know, but I thought it would still be getting the data even though the XML doc has a 500 Internel Server Error)

Warning: simplexml_load_file(http://psnapi.com.ar/ps3/api/psn.asmx/getPSNID?sPSNID=jameslfc19) [function.simplexml-load-file]: failed to open stream: HTTP request failed! HTTP/1.1 500 Internal Server Error in /Applications/XAMPP/xamppfiles/htdocs/Sigs/PSN2.php on line 6

What is the best way to do this? I'm assuming that the error im ignoring with @ is causing the problem.

In the comments on simlexml_load_file on php.net I found the following. Not tested, but worth a try.

sean at aliencreations dot com 17-Mar-2011 10:59 If you find that you are receiving 500 errors with simplexml_load_file() but you can access the xml/rss feed manually through a browser, your script is probably being blocked by a user agent sniffer.

Add this code before your xml call to remedy this issue

<?php

ini_set("user_agent","Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)");
ini_set("max_execution_time", 0);
ini_set("memory_limit", "10000M");

$rss = simplexml_load_file($feed_url);

?>