diff --git a/examples/auth_guest_with_note.php b/examples/auth_guest_with_note.php index 0aa64a7..bac529e 100755 --- a/examples/auth_guest_with_note.php +++ b/examples/auth_guest_with_note.php @@ -3,7 +3,9 @@ * PHP API usage example * * contributed by: Art of WiFi - * description: example basic PHP script to auth a guest device and attach a note to it + * description: example basic PHP script to auth a guest device and attach a note to it, + * this requires the device to be connected to the WLAN/LAN at moment of + * authorization */ /** diff --git a/examples/update_ac-iw_ports.php b/examples/update_ac-iw_ports.php new file mode 100755 index 0000000..fd5aeb4 --- /dev/null +++ b/examples/update_ac-iw_ports.php @@ -0,0 +1,78 @@ +'; + +/** + * the MAC address of the AC-IW device to modify + */ +$device_mac = ''; + +/** + * port configuration to apply to port #1 of the AC-IW device + * NOTE: available port configurations are available through list_portconf() + */ +$port_conf_id_port_1 = '<_id of port configuration to apply to port #1>'; + +/** + * port configuration to apply to port #2 of the AC-IW device + * NOTE: available port configurations are available through list_portconf() + */ +$port_conf_id_port_2 = '<_id of port configuration to apply to port #2>'; + +/** + * prepare the payload to pass on to the API endpoint + */ +$new_ports_config = [ + 'port_overrides' => [ + [ + 'port_idx' => 1, + 'portconf_id' => $port_conf_id_port_1 + ], + [ + 'port_idx' => 2, + 'portconf_id' => $port_conf_id_port_2 + ] + ] +]; + +/** + * initialize the UniFi API connection class and log in to the controller and do our thing + */ +$unifi_connection = new UniFi_API\Client($controlleruser, $controllerpassword, $controllerurl, $site_id, $controllerversion, false); +$set_debug_mode = $unifi_connection->set_debug(false); +$loginresults = $unifi_connection->login(); +$data = $unifi_connection->list_devices($device_mac); +$device_id = $data[0]->device_id; +$update_device = $unifi_connection->set_device_settings_base($device_id, $new_ports_config); + +if(!$update_device){ + $error = $unifi_connection->get_last_results_raw(); + echo json_encode($error, JSON_PRETTY_PRINT); +} + +/** + * provide feedback in json format + */ +echo json_encode($update_device, JSON_PRETTY_PRINT); \ No newline at end of file diff --git a/examples/update_wlan_settings_5.5.X.php b/examples/update_device_wlan_settings_5.5.X.php similarity index 93% rename from examples/update_wlan_settings_5.5.X.php rename to examples/update_device_wlan_settings_5.5.X.php index 28826e4..847a363 100755 --- a/examples/update_wlan_settings_5.5.X.php +++ b/examples/update_device_wlan_settings_5.5.X.php @@ -3,7 +3,7 @@ * PHP API usage example * * contributed by: Art of WiFi - * description: example basic PHP script to update WLAN settings when using a controller version 5.5.X or higher + * description: example basic PHP script to update WLAN settings of a device when using a controller version 5.5.X or higher * where set_ap_radiosettings() throws an error */