-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtable.php
34 lines (30 loc) · 864 Bytes
/
table.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
$server_token = 'XXXXXXXXXXX'; // Renseignez la token de votre serveur présente sur votre fiche Top-Serveurs
$response = @file_get_contents("https://api.top-serveurs.net/v1/servers/$server_token/players-ranking");
$json = json_decode($response);
if (!$json || $json->code !== 200) {
echo 'Erreur lors la récupération des données';
die;
}
$table = '
<table>
<thead>
<tr>
<th>Pseudo</th>
<th>Votes</th>
</tr>
</thead>
<tbody>
';
foreach ($json->players as $player) {
$table .="
<tr>
<td>$player->playername</td>
<td>$player->votes</td>
</tr>
";
}
$table .= "
</tbody>
</table>";
echo $table;