I'm writing a PHP script that retrieves steam user profile information (for a servers forum/website I'm making), and I seem to be stuck on getting the xml file. To get the data in xml format, the address is http://steamcommunity.com/profiles/<steam 64 id>/?xml=1
The issue is that it doesn't seem to actually be passing the ?xml=1 as GET data, but instead, possibly ignoring it. Here is by code:
function parseSteamInformation( $steamid ) {
$result = file_get_contents( "http://steamcommunity.com/profiles/$steamid/?xml=1" );
$xml = simplexml_load_string( $result );
if( $xml ) {
$data = array(
"id64" => $xml->steamID64,
"steamName" => $xml->steamID,
"onlineState" => $xml->onlineState,
"stateMessage" => $xml->stateMessage,
"avatarIcon" => $xml->avatarFull,
"vacBanned" => $xml->vacBanned,
"steamRating" => $xml->steamRating,
"realName" => $xml->realName,
);
return $data;
}
return false;
}
The result string is actually HTML instead of XML, but according to https://partner.steamgames.com/documentation/community_data , adding ?xml=1 should output XML.
I looked at content streaming, and tried adding:
$data = http_build_query(array("xml"=>1)); // needed somewhere?
$context = stream_context_create(array(
'http' => array(
'method' => 'GET',
'header' => "Accept-language: en\r\n" .
"Cookie: xml=1\r\n"
)
));
$result = file_get_contents( "http://steamcommunity.com/profiles/${steamid}/", false, $context );
Because google didn't reveal much information on passing GET parameters to a website with file _get_contents(), I'm assuming I'm over-complicating something.
Any help is appreciated, -Oz