Guest User

ajax.php

a guest
Dec 8th, 2019
97
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. // ajax.php for pulling servers from truckersmp.
  3. //© 2016 Robert Foster
  4. $data = json_decode( file_get_contents( 'https://api.truckersmp.com/v2/servers' ) );
  5. //loop through all servers listed on TruckersMP Api
  6. foreach ( $data->response as $cat ) { ?>
  7.  
  8.         <!-- Loop the information we want-->
  9.         Server ID: <?php echo $cat->id; ?>
  10.         <?php echo "<br>"?>
  11.         Game Name: <?php echo $cat->name; ?>
  12.         <?php echo "<br>"?>
  13.         Player Count: <?php echo $cat->players; ?>
  14.         <?php echo "<br>"?>
  15.    <?php } ?>
RAW Paste Data