I need to get the object online that is inside the "players" object but I can not get it ... I can only get objects that are "In the root" json where I need to get:
{
"status": true,
"hostname": "skyminigames.com.br",
"port": 25565,
"protocol": "tcp",
"ping": 126,
"players": {
"online": 3376,
"max": 8500
},
"cached": false
}
Code I am using:
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, 'https://use.gameapis.net/mc/query/players/skyminigames.com.br');
$result = curl_exec($ch);
curl_close($ch);
$obj = json_decode($result);
echo "$obj->players->online";
?>