i try to use steam api and i called an response and formatted it by code:
$url = 'http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key='.$key.'&steamids='.$id;
$json = json_decode(file_get_contents($url));
$steam_array = (array) $json;
print_r of $json:
stdClass Object ( [response] => stdClass Object ( [players] => Array ( [0] => stdClass Object ( [steamid] => 76561198092269637 [communityvisibilitystate] => 3 [profilestate] => 1 [personaname] => NoAd [lastlogoff] => 1527501715 [profileurl] => https://steamcommunity.com/id/noad/ [avatar] => https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/29/29f37f0a8b3b1d3dd0d7bb4c19f6bded0a417cad.jpg [avatarmedium] => https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/29/29f37f0a8b3b1d3dd0d7bb4c19f6bded0a417cad_medium.jpg [avatarfull] => https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/29/29f37f0a8b3b1d3dd0d7bb4c19f6bded0a417cad_full.jpg [personastate] => 1 [realname] => Adam Nowak [primaryclanid] => 103582791429521408 [timecreated] => 1369457346 [personastateflags] => 0 [loccountrycode] => PL [locstatecode] => 35 [loccityid] => 35736 ) ) ) )
print_r of $steam_array
Array ( [response] => stdClass Object ( [players] => Array ( [0] => stdClass Object ( [steamid] => 76561198092269637 [communityvisibilitystate] => 3 [profilestate] => 1 [personaname] => NoAd [lastlogoff] => 1527501715 [profileurl] => https://steamcommunity.com/id/noad/ [avatar] => https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/29/29f37f0a8b3b1d3dd0d7bb4c19f6bded0a417cad.jpg [avatarmedium] => https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/29/29f37f0a8b3b1d3dd0d7bb4c19f6bded0a417cad_medium.jpg [avatarfull] => https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/29/29f37f0a8b3b1d3dd0d7bb4c19f6bded0a417cad_full.jpg [personastate] => 1 [realname] => Adam Nowak [primaryclanid] => 103582791429521408 [timecreated] => 1369457346 [personastateflags] => 0 [loccountrycode] => PL [locstatecode] => 35 [loccityid] => 35736 ) ) ) )
how to call variables in one of this mess ? if i use var_dump($json) it leaves class to.
i tried:
echo $steam_array->value["players"][0]['avatarfull'];
echo $steam_array->value["avatarfull"];
i'm not familliar yet with classes and objects in php :/
i wanted to have it like this
$steam_array[0]['avatarfull'];
[0] is important becouse this api request can catch more than one person
Hi $steam_array
is an array and you are calling it as object so call it like as array kindly check below.
$steam_array['response']->players[0]->steamid
steamid And your all fields.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.