PHP code example of intensa / outline-api-client

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

    

intensa / outline-api-client example snippets




use OutlineApiClient\OutlineApiClient;

try {

    // Your Outline server address
    $serverUrl = 'https://127.0.0.1:3333/YZwl3D1r-B6cNYzQ';

    $api = new OutlineApiClient($serverUrl);

    // Get an array of all server keys
    $keysList = $api->getKeys();

    // Create new key
    $key = $api->create();

    // Rename exist key.
    // Passing key id and new name
    $api->setName($key['id'], 'New key name');

    // Set transfer data limit for key.
    // Passing key id and limit in bytes.
    // In the example set 5MB
    $api->setLimit($key['id'], 5 * 1024 * 1024);

    // Remove key limit
    // Passing key id
    $api->deleteLimit($key['id']);

    // Delete key
    $api->delete($key['id']);

    // Get an array of used traffic for all keys
    $transferData = $api->metricsTransfer();
} catch (\Exception $e) {
    // Handle exception
}


OutlineApiClient\OutlineKey;

try {

    // Your Outline server address
    $serverUrl = 'https://127.0.0.1:3333/YZwl3D1r-B6cNYzQ';

    // Key id
    $keyId = 1;
    
    // Initializing an object and getting key data
    $key = (new OutlineKey($serverUrl))->load($keyId);
    
    // Get key id
    $key->getId();
    
    // Get key name
    $key->getName();
    
    // Get key transfer traffic
    $key->getTransfer();
    
    // Get access link 
    $key->getAccessUrl();

    // Rename exist key.
    // Passing key id and new name
    $key->rename('New name');

    // Set transfer data limit for key.
    // Passing limit in bytes.
    // In the example set 5MB
    $key->limit(5 * 1024 * 1024);

    // Remove key traffic limit
    $key->deleteLimit();
    
    // Delete key
    $key->delete();
    
} catch (\Exception $e) {
    // Handle exception
}



OutlineApiClient\OutlineKey;

try {
    // Your Outline server address
    $serverUrl = 'https://127.0.0.1:3333/YZwl3D1r-B6cNYzQ';
    
    // Initializing an object and creating new key
    // Passing to method create() key name and traffic limit (optional)
    $key = (new OutlineKey($serverUrl))->create('Key name', 5 * 1024 * 1024);

} catch (\Exception $e) {

}