PHP code example of tomb1n0 / unifiapi

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

    

tomb1n0 / unifiapi example snippets



  
ace these with your own details.
define('UNIFI_URL', 'https://unifi.yourdomain.co.uk:8443');
define('UNIFI_SITE', 'Southampton');
define('UNIFI_USERNAME', 'admin');
define('UNIFI_PASSWORD', 'unifipassword');

// get an instance of the api
$api = new UnifiAPI\API(UNIFI_URL, UNIFI_SITE, UNIFI_USERNAME, UNIFI_PASSWORD);

// get a controller object
$controller = $api->controller();

$health = $controller->health();

$wlan_health = $health[0];
$wan_health = $health[1];
$www_health = $health[2];
$lan_health = $health[3];
$vpn_health = $health[4];

echo 'Num Adopted APs: ' . $wlan_health['num_adopted'];

// get any unadopted WAPs
$devices = $controller->unadopted_devices();

// Adopt each of them
foreach ($devices as $device) {
    $device->adopt();
}