i am using php to get the json values and have no problem looping though the data and echoing the SteamName, Level, Experience and more. However I do not know how to echo the steamid number 7656119801319... per proile.
json file:
{
"FURNACES": {},
"PROFILE": {
"76561198013191579": {
"SteamName": "Cayos",
"Level": 22,
"Experience": 1592,
"Agility": 22,
"Strength": 22,
"Intelligence": 22,
"StatsPoints": 66,
"SkillPoints": 2,
"Skills": {
"lumberjack": 20
},
"Preferences": {
"ShowXPMessagePercent": 0.25,
"ShowCraftMessage": true,
"UseBlinkArrow": true,
"AutoToggleBlinkArrow": true
}
},
"76561198113765447": {
"SteamName": "CaptainCheesy",
"Level": 31,
"Experience": 3576,
"Agility": 31,
"Strength": 70,
"Intelligence": 70,
"StatsPoints": 15,
"SkillPoints": 5,
"Skills": {
"miner": 8,
"lumberjack": 10,
"hunter": 8
},
"Preferences": {
"ShowXPMessagePercent": 0.25,
"ShowCraftMessage": true,
"UseBlinkArrow": true,
"AutoToggleBlinkArrow": true
}
},
"76561198141845337": {
"SteamName": "Carrot",
"Level": 3,
"Experience": 409,
"Agility": 3,
"Strength": 3,
"Intelligence": 3,
"StatsPoints": 9,
"SkillPoints": 3,
"Skills": {},
"Preferences": {
"ShowXPMessagePercent": 0.25,
"ShowCraftMessage": true,
"UseBlinkArrow": true,
"AutoToggleBlinkArrow": true
}
},
"76561198012539649": {
"SteamName": "Booglee",
"Level": 3,
"Experience": 110,
"Agility": 3,
"Strength": 3,
"Intelligence": 3,
"StatsPoints": 9,
"SkillPoints": 3,
"Skills": {},
"Preferences": {
"ShowXPMessagePercent": 0.25,
"ShowCraftMessage": true,
"UseBlinkArrow": true,
"AutoToggleBlinkArrow": true
}
},
"333228975": {
"SteamName": "SYN Gaurd",
"Level": 0,
"Experience": 0,
"Agility": 0,
"Strength": 0,
"Intelligence": 0,
"StatsPoints": 0,
"SkillPoints": 0,
"Skills": {},
"Preferences": {
"ShowXPMessagePercent": 0.25,
"ShowCraftMessage": true,
"UseBlinkArrow": true,
"AutoToggleBlinkArrow": true
}
}
}
}
My PHP Code:
$url = 'C:\Users\plosey\Desktop\GameServers\Rust\steam\server_syn1\server\syn1\oxide\data\Hunt_Data.json'; //Url to the cars api
$content = file_get_contents($url);
$json = json_decode($content);
foreach($json->PROFILE as $user) {
echo $user->SteamName;
echo $user->NEED STEAM ID HERE; // This is the line that is not correct.
}
so in short i would need to not only echo the SteamName but the Steamid number from the same profile.
Instead of
foreach($json->PROFILE as $user) {
use
foreach ($json->PROFILE as $steamid => $user) {
Try below code to print id. $stremId will print your ID. You can replace it with any variable name.
$json = json_decode($json);
foreach($json->PROFILE as $streamId => $user) {
echo $user->SteamName;
echo $streamId;
}
try this
foreach($json->PROFILE as $key => $user) {
echo $key .' => '.$user->SteamName."<br/>";
}
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.