PHP code example of edvardpotter / outline-manager-client

1. Go to this page and download the library: Download edvardpotter/outline-manager-client 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/ */

    

edvardpotter / outline-manager-client example snippets




utlineManagerClient\OutlineClient;

$url = 'https://1.1.1.1:5155/lrd5SuLajnsTIdvszo_VA/';

/* Create outline client */
$api = new OutlineClient($url);

/* Or create with your own guzzle http client */
$guzzleClient = new \GuzzleHttp\Client([
    'uri' => $url
]);

$api = new OutlineClient('', $guzzleClient);

/* Get server info */
$server = $api->getServer();
echo $server->getName();
echo $server->getServerId();
echo $server->getVersion();
echo $server->getHostnameForAccessKeys();
echo $server->getPortForNewAccessKeys();
echo $server->getCreatedTimestampMs();

/* Set server name */
$api->setServerName('My outline server');

/* Set server port */
$api->setServerPortForNewKeys(42314);

/* Get array key collection (array<id, KeyType>) */
$keysList = $api->getKeys();
foreach ($keysList as $id => $key) {
    echo $key->getId();
    echo $key->getName();
    echo $key->getUsedBytes();
    echo $key->getAccessUrl();
    echo $key->getPort();
    /* ... */
}

/* Create new key with name */
$key = $api->addKey('First key');

/* Or set key after creating */
$key = $api->addKey();
$api->setKeyName($key->getId(), 'First key');

/* Get key by id */
$api->getKeyById(123);

/* Set key data limit in bytes by key id. In the example set 10GB */
$api->setKeyDataLimit($key->getId(), 10 * 1024 * 1024 *1024);

/* Unset key data limit by key id */
$api->unsetKeyDataLimit($key->getId());

/* Delete key */
$api->deleteKey($key->getId());

/* Set default data limit (for all keys) */
$api->setDefaultDataLimit(10 * 1024 * 1024 *1024);

/* Unset default data limit */
$api->unsetDefaultDataLimit();

/* Get an array of used traffic for all keys */
$usedBytes = $api->getUsedBytes();