コード例 #1
0
<?php

require '../vendor/autoload.php';
use PrimeInc\EdgeApi\Endpoint;
use PrimeInc\EdgeApi\Client;
if (class_exists('\\Whoops\\Run')) {
    $whoops = new \Whoops\Run();
    $whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler());
    $whoops->register();
}
//create new endpoint config
$endpoint = new Endpoint(array('name' => 'edgeRouter', 'protocol' => 'https', 'domain' => '192.168.1.1', 'port' => '443', 'username' => 'ubnt', 'password' => 'ubnt', 'verify' => true));
$client = new Client($endpoint);
// get auth cookies (only required because I'm not making any other api calls)
$client->auth();
// serialize the endpoint, so you can save it for another request
// this way you don't have to login multiple times.
$serializedEndpoint = serialize($endpoint);
// this is to show that when you unserialize it, it becomes an Endpoint object
$endpoint2 = unserialize($serializedEndpoint);
$client2 = new Client($endpoint2);
$client2->data('dhcp_leases');
echo '<pre>';
echo $client2->prettyJson();
コード例 #2
0
ファイル: basic.php プロジェクト: primeinc/edgeapi
<?php

require '../vendor/autoload.php';
use PrimeInc\EdgeApi\Endpoint;
use PrimeInc\EdgeApi\Client;
if (class_exists('\\Whoops\\Run')) {
    $whoops = new \Whoops\Run();
    $whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler());
    $whoops->register();
}
//create new endpoint config
$endpoint = new Endpoint(array('name' => 'edgeRouter', 'protocol' => 'https', 'domain' => '192.168.1.1', 'port' => '443', 'username' => 'ubnt', 'password' => 'ubnt', 'verify' => true));
$client = new Client($endpoint);
echo '<pre>';
$client->data('sys_info');
echo $client->prettyJson();
// this will grab the last data fetched automatically
$dhcp_stats = $client->data('dhcp_stats');
echo $client->prettyJson($dhcp_stats);
// or you can feed it data
// gets a pre-defined config structure (looks like at least a vast majority of the device config)
$client->get();
//This one takes a while
echo $client->prettyJson();
コード例 #3
0
ファイル: save-cfg.php プロジェクト: primeinc/edgeapi
<?php

require '../vendor/autoload.php';
use PrimeInc\EdgeApi\Endpoint;
use PrimeInc\EdgeApi\Client;
if (class_exists('\\Whoops\\Run')) {
    $whoops = new \Whoops\Run();
    $whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler());
    $whoops->register();
}
//create new endpoint config
$endpoint = new Endpoint(array('name' => 'edgeRouter', 'protocol' => 'https', 'domain' => '192.168.1.1', 'port' => '443', 'username' => 'ubnt', 'password' => 'ubnt', 'verify' => true));
$client = new Client($endpoint);
//force downloads archive
$client->save(false);