PHP code example of s4wny / cloud-royale-api

1. Go to this page and download the library: Download s4wny/cloud-royale-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/ */

    

s4wny / cloud-royale-api example snippets




loudRoyaleAPI\CloudRoyaleAPI;

$api = new CloudRoyaleAPI("[email protected]", "123456");

// Login
var_dump($api->login());

// Get all your servers ( [ID => server name] )
$servers = $api->getServers();
print_r($servers);

// Get status about a specific server
$firstServer = key($servers);
print_r(json_decode($api->getStatus($firstServer)));

/* Output:

bool(true)

Array
(
    [0] => Array
        (
            [ip] => 1.2.3.4
            [id] => sadffsd34rfxd3
            [name] => http server
            [online] => false
        )

    [1] => Array
        (
            [ip] => 4.4.4.4
            [id] => asfdsadf
            [name] => vpn
            [online] => true
        )
)

stdClass Object
(
    [sadffsd34rfxd3] => stdClass Object
        (
            [status] => On
            [memory] => 8
            [cpus] => 3
            [disk_size] => 30
            [disks] => stdClass Object
                (
                    [1337] => stdClass Object
                        (
                            [size] => 30
                            [storage] => 13
                        )
                )
        )
)
*/