SHARE
TWEET

ajax.php

a guest Dec 8th, 2019 71 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
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top