'; /** * the MAC address of the AC-IW device to re-configure */ $device_mac = ''; /** * port configuration id to apply to port #1 of the AC-IW device * NOTE: port configurations are available through list_portconf() */ $port_conf_id_port_1 = '<_id of port configuration to apply to port #1>'; /** * port configuration id to apply to port #2 of the AC-IW device * NOTE: 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 ); $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);