PHP code example of drteam / uon

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

    

drteam / uon example snippets



ain object for work with API
$uon = new \Uon\Client(['token' => 'some_token']);

// Some examples
$users    = $uon->users->all();        // Get a list of all users
$user     = $uon->users->get(1);       // Get user by unique id
$request  = $uon->requests->get(1);    // Get request by unique ID
$managers = $uon->managers->all();     // Get list of managers

// Enable config class
use \Uon\Config;

// Class with configuration options
$config = new Config();
$config
    ->set('token', 'some_token')
    ->set('timeout', 10);

// Or like this
$config = new Config([
    'token'   => 'some_token',
    'timeout' => 10
]);

use \Uon\Config;
use \Uon\Client;

$config = new Config([
    'token'   => 'some_token',
    'timeout' => 10
]);

$client = new Client($config);

use \Uon\Client;

$client = new Client([
    'token'   => 'some_token',
    'timeout' => 10
]);

use \Uon\Client;

$client = new Client(['token' => 'some_token']);

$config = new \Uon\Config([
    'token'   => 'some_token',
    'timeout' => 100,
    'tries'   => 20,
    'seconds' => 2
]);

$results = [];

$i=1;
while (true) { // yeah, I know it's bad, better to use recursion
    $response  = $uon->requests->get($i);
    $results[] = $response;

    // Exit from loop if less than 100 items in answer from server
    if (count($response->message) < 100) {
        break;
    }
    $i++;
}
print_r($results);