2
I need to pick up the object "online" that is inside the object "players" more I can’t catch... I can only pick up objects that are "At the root" json where I need to pick up:
{
"status": true,
"hostname": "skyminigames.com.br",
"port": 25565,
"protocol": "tcp",
"ping": 126,
"players": {
"online": 3376,
"max": 8500
},
"cached": false
}
Code I’m 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";
?>
Do not forget to approve the answer of Laerte. Since it is correct.
– Andrei Coelho