nitrado / NitrAPI-PHP

PHP based SDK for the NitrAPI
https://server.nitrado.net/
MIT License
16 stars 11 forks source link

List Whitelist #79

Open ampsite opened 1 year ago

ampsite commented 1 year ago

can anybody help me? I am trying to view the tags in the list using php. I don't know how to use the API.

ItsMeStevieG commented 1 year ago

Getting the users on the whitelist can be done like this:

require_once 'vendor/autoload.php'; // Load Composer's autoloader

use Nitrapi\Nitrapi;

$nitrapi = new Nitrapi('your_api_key', 'your_api_secret');

// Define the server ID for the game server you want to retrieve the whitelist for
$serverId = 'your_server_id';

try {
    // Get the whitelist for the specified server
    $whitelist = $nitrapi->gameservers->getServerWhitelist($serverId);

    // Print the whitelist entries
    foreach ($whitelist as $entry) {
        echo "Player: " . $entry->getUsername() . "\n";
    }
} catch (Exception $e) {
    echo "Error: " . $e->getMessage();
}
ozonostudio commented 3 months ago

Whitelist not longer working, now display a 501 error