2015-08-09 19:06:47 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
require __DIR__ . '/../vendor/autoload.php';
|
|
|
|
$config = require 'config.php';
|
|
|
|
|
|
|
|
use JVDS\UnifiApiClient\Client;
|
|
|
|
use GuzzleHttp\Client as HttpClient;
|
|
|
|
use GuzzleHttp\Exception\RequestException;
|
|
|
|
|
|
|
|
$apiClient = new Client(new HttpClient(['base_uri' => $config['base_uri']]));
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
// login to the unifi controller API
|
|
|
|
$apiClient->login($config['username'], $config['password']);
|
|
|
|
|
|
|
|
// Revoke authorization for guest with mac address 01:01:01:01:01:01
|
|
|
|
// You need a user with full access to the unifi controller for this call!
|
2015-11-21 15:01:34 +00:00
|
|
|
$response = $apiClient->unauthorizeGuest($config['site'], '01:01:01:01:01:01');
|
2015-08-09 19:06:47 +00:00
|
|
|
|
2015-11-21 15:01:34 +00:00
|
|
|
print_r(json_decode($response->getBody(), true));
|
2015-08-09 19:06:47 +00:00
|
|
|
|
|
|
|
$apiClient->logout();
|
|
|
|
|
|
|
|
} catch (RequestException $e) {
|
|
|
|
echo $e->getMessage() . PHP_EOL;
|
|
|
|
|
|
|
|
echo '----- Request ------' . PHP_EOL;
|
2015-11-21 15:01:34 +00:00
|
|
|
|
|
|
|
echo (string) $e->getRequest()->getBody();
|
2015-08-09 19:06:47 +00:00
|
|
|
echo PHP_EOL;
|
|
|
|
|
|
|
|
echo '----- Response ------' . PHP_EOL;
|
|
|
|
echo $e->hasResponse() ? $e->getResponse()->getBody()->getContents() : '- no response -';
|
|
|
|
echo PHP_EOL;
|
|
|
|
}
|