PHP code example of timdesm / pterodactyl-php-api

1. Go to this page and download the library: Download timdesm/pterodactyl-php-api library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

timdesm / pterodactyl-php-api example snippets


$pterodactylApi = new \Timdesm\PterodactylPhpApi\PterodactylApi(BASE_URI_HERE, API_KEY_HERE, API_TYPE_HERE);

use Timdesm\PterodactylPhpApi\PterodactylApi;
$pterodactylApi = new PterodactylApi(BASE_URI_HERE, API_KEY_HERE, API_TYPE_HERE);

// Fetch the current user's API keys
$client = new PterodactylApi('https://panel.example.com', 'client-token', 'client');
$keys = $client->account->apiKeys();

// Schedule a power action on a server
$schedule = $client->server_schedules->create($serverId, [
    'name'        => 'Restart every night',
    'cron_day_of_week' => '*',
    'cron_day_of_month' => '*',
    'cron_hour'   => '3',
    'cron_minute' => '0',
    'is_active'   => true,
]);

$client->server_schedules->createTask($serverId, $schedule->id, [
    'action'     => 'power',
    'payload'    => 'restart',
    'time_offset'=> 0,
]);
bash
$ composer