unifi-php-api/examples/ap_upgrade_firmware.php
malle-pietje d7827fdbf1 General code cleanup (replace tabs by spaces, etc.)
Finalised merge of PRs #10, #11, #12 and #13
Methods/functions added:
- list_country_codes()
- set_guestlogin_settings_base()
- set_site_connectivity()
- set_site_country()
- set_site_guest_access()
- set_site_locale()
- set_site_mgmt()
- set_site_name()
- set_site_ntp()
- set_site_snmp()
Examples added:
- ap_upgrade_firmware.php
- site_provisioning_example
- update_ac-iw_ports.php
2018-03-24 10:46:42 +01:00

37 lines
1.1 KiB
PHP
Executable File

<?php
/**
* PHP API usage example
*
* contributed by: @4oo4
* description: example script to check and upgrade device firmware (can be scheduled with systemd/cron)
* to the most current version
*/
require_once('vendor/autoload.php');
require_once('config.php');
/**
* site id of the AP to update
*/
$site_id = '<enter your site id here>';
/**
* device MAC address formatted with colons, e.g. 'de:ad:be:ef:01:23'
*/
$device_mac = '<enter MAC address of device to update>';
/**
* initialize the UniFi API connection class, log in to the controller
* (this example assumes you have already assigned the correct values in config.php to the variables used)
*/
$unifi_connection = new UniFi_API\Client($controlleruser, $controllerpassword, $controllerurl, $site_id, $controllerversion, false);
$login = $unifi_connection->login();
/**
* Run the actual upgrade
*/
$results = $unifi_connection->upgrade_device($device_mac);
/**
* provide feedback in json format from $response given by upgrade_device();
*/
echo json_encode($results, JSON_PRETTY_PRINT);