альтернативное решение, может быть медленнее, чем другие, но, скорее всего, по какой-то причине намечено, но надеюсь, что это поможет
<code><?php
function strip_cdata($string)
{
preg_match_all('/<!\[cdata\[(.*?)\]\]>/is', $string, $matches);
return str_replace($matches[0], $matches[1], $string);
}
function get_steam($profile){
//make steam think its a browser
ini_set('user_agent', 'Mozilla/5.0 (Windows; U; Windows NT 6.0; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3');
ini_set('default_socket_timeout',5);
$return ='';
if(isset($profile) && is_numeric($profile)){
$spg=file_get_contents('http://steamcommunity.com/profiles/'.$profile.'/?xml=1');
if($spg==true){
preg_match('/<steamID64>(.*)<\/steamID64>/i',$spg,$matchSID);
preg_match('/<steamID>(.*)<\/steamID>/i',$spg,$matchSName);
preg_match('/<onlineState>(.*)<\/onlineState>/i',$spg,$matchSStatus);
preg_match('/<stateMessage>(.*)<\/stateMessage>/i',$spg,$matchSLastOnline);
preg_match('/<vacBanned>(.*)<\/vacBanned>/i',$spg,$matchSBanned);
preg_match('/<avatarFull>(.*)<\/avatarFull>/i',$spg,$matchSAvatar);
preg_match('/<memberSince>(.*)<\/memberSince>/i',$spg,$matchSSignUp);
preg_match('/<steamRating>(.*)<\/steamRating>/i',$spg,$matchSRating);
preg_match('/<location>(.*)<\/location>/i',$spg,$matchSLocation);
preg_match('/<realname>(.*)<\/realname>/i',$spg,$matchSRealName);
preg_match('/<summary>(.*)<\/summary>/i',$spg,$matchSummary);
$data = array(
"id64" => $matchSID[1],
"steamName" => strip_cdata($matchSName[1]),
"onlineState" => strip_cdata($matchSStatus[1]),
"stateMessage" => strip_cdata($matchSLastOnline[1]),
"avatarIcon" => strip_cdata($matchSAvatar[1]),
"memberSince" => $matchSSignUp[1],
"vacBanned" => $matchSBanned[1],
"steamRating" => $matchSRating[1],
"steamLocation" => strip_cdata($matchSLocation[1]),
"realName" => strip_cdata($matchSRealName[1]),
"summary" => strip_cdata($matchSummary[1])
);
return $data;
}else{
return "E2";}
}else{return "E1";}
}
//do the function
$steamData=get_steam('76561197968575517');
//check the results
if($steamData=='E1'){
echo'Profile ID not set.';
}elseif($steamData=='E2'){
echo'Error Connecting to Steam Profile.';
}else{
//output example
echo '<pre>';
foreach($steamData as $key => $value){
echo ''.$key.'-'.$value.'<br>';
}
echo'
';
}
?>