Skip to content

Commit 62ba4b6

Browse files
authored
Merge branch 'Art-of-WiFi:master' into tests
2 parents eefcb65 + e89daaf commit 62ba4b6

31 files changed

+513
-154
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ The class automatically detects UniFi OS-based controllers and adjusts URLs and
3535
If your own code implements strict validation of the URL that is passed to the constructor, please adapt your
3636
logic to allow URLs without a port suffix or with port 443 when working with a UniFi OS-based controller.
3737

38+
> **IMPORTANT NOTE**: cookies are no longer supported with UniFi OS-based controllers. If your application code does use cookies,
39+
they will be ignored automatically when working with UniFi OS-based controllers.
40+
3841
Please test all methods you plan on using thoroughly before using the API Client with
3942
UniFi OS devices in a production environment.
4043

examples/ap_scanning_state.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,14 @@
2828
* initialize the UniFi API connection class and log in to the controller and do our thing
2929
* spectrum_scan_state()
3030
*/
31-
$unifi_connection = new UniFi_API\Client($controlleruser, $controllerpassword, $controllerurl, $site_id, $controllerversion);
31+
$unifi_connection = new UniFi_API\Client(
32+
$controlleruser,
33+
$controllerpassword,
34+
$controllerurl,
35+
$site_id,
36+
$controllerversion
37+
);
38+
3239
$set_debug_mode = $unifi_connection->set_debug($debug);
3340
$loginresults = $unifi_connection->login();
3441
$data = $unifi_connection->spectrum_scan_state($ap_mac);

examples/ap_upgrade_firmware.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,15 @@
2424
* initialize the UniFi API connection class, log in to the controller
2525
* (this example assumes you have already assigned the correct values in config.php to the variables used)
2626
*/
27-
$unifi_connection = new UniFi_API\Client($controlleruser, $controllerpassword, $controllerurl, $site_id, $controllerversion, false);
28-
$login = $unifi_connection->login();
27+
$unifi_connection = new UniFi_API\Client(
28+
$controlleruser,
29+
$controllerpassword,
30+
$controllerurl,
31+
$site_id,
32+
$controllerversion
33+
);
34+
35+
$login = $unifi_connection->login();
2936

3037
/**
3138
* Run the actual upgrade

examples/auth_guest_basic.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,16 @@
4545
/**
4646
* initialize the UniFi API connection class and log in to the controller
4747
*/
48-
$unifi_connection = new UniFi_API\Client($controlleruser, $controllerpassword, $controllerurl, $site_id, $controllerversion);
49-
$set_debug_mode = $unifi_connection->set_debug($debug);
50-
$loginresults = $unifi_connection->login();
48+
$unifi_connection = new UniFi_API\Client(
49+
$controlleruser,
50+
$controllerpassword,
51+
$controllerurl,
52+
$site_id,
53+
$controllerversion
54+
);
55+
56+
$set_debug_mode = $unifi_connection->set_debug($debug);
57+
$loginresults = $unifi_connection->login();
5158

5259
/**
5360
* then we authorize the device for the requested duration

examples/auth_guest_with_note.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,16 @@
4242
/**
4343
* initialize the UniFi API connection class and log in to the controller
4444
*/
45-
$unifi_connection = new UniFi_API\Client($controlleruser, $controllerpassword, $controllerurl, $site_id, $controllerversion);
46-
$set_debug_mode = $unifi_connection->set_debug($debug);
47-
$loginresults = $unifi_connection->login();
45+
$unifi_connection = new UniFi_API\Client(
46+
$controlleruser,
47+
$controllerpassword,
48+
$controllerurl,
49+
$site_id,
50+
$controllerversion
51+
);
52+
53+
$set_debug_mode = $unifi_connection->set_debug($debug);
54+
$loginresults = $unifi_connection->login();
4855

4956
/**
5057
* we authorize the device for the requested duration and attach the note to it's object

examples/block_list.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,16 @@
4242
/**
4343
* initialize the UniFi API connection class and log in to the controller
4444
*/
45-
$unifi_connection = new UniFi_API\Client($controlleruser, $controllerpassword, $controllerurl, $site_id, $controllerversion);
46-
$set_debug_mode = $unifi_connection->set_debug($debug);
47-
$loginresults = $unifi_connection->login(); // always true regardless of site id
45+
$unifi_connection = new UniFi_API\Client(
46+
$controlleruser,
47+
$controllerpassword,
48+
$controllerurl,
49+
$site_id,
50+
$controllerversion
51+
);
52+
53+
$set_debug_mode = $unifi_connection->set_debug($debug);
54+
$loginresults = $unifi_connection->login(); // always true regardless of site id
4855

4956
foreach ($macs_to_block as $mac) {
5057
// block_result is always true even if mac address does not exist :(

examples/change_super_mgmt.php

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,26 @@
2525
/**
2626
* initialize the UniFi API connection class and log in to the controller and do our thing
2727
*/
28-
$unifi_connection = new UniFi_API\Client($controlleruser, $controllerpassword, $controllerurl, $site_id, $controllerversion, true);
29-
$set_debug_mode = $unifi_connection->set_debug($debug);
30-
$loginresults = $unifi_connection->login();
31-
$site_settings = $unifi_connection->list_settings();
28+
$unifi_connection = new UniFi_API\Client(
29+
$controlleruser,
30+
$controllerpassword,
31+
$controllerurl,
32+
$site_id,
33+
$controllerversion
34+
);
3235

33-
$super_mgmt_settings = [];
36+
$set_debug_mode = $unifi_connection->set_debug($debug);
37+
$loginresults = $unifi_connection->login();
38+
$site_settings = $unifi_connection->list_settings();
39+
40+
$super_mgmt_settings = [];
3441
$super_mgmt_settings_id = '';
3542

3643
if (!empty($site_settings)) {
37-
foreach($site_settings as $section) {
44+
foreach ($site_settings as $section) {
3845
echo 'section key: ' . $section->key . PHP_EOL;
3946
if ($section->key === 'super_mgmt') {
40-
$super_mgmt_settings = $section;
47+
$super_mgmt_settings = $section;
4148
$super_mgmt_settings_id = $section->_id;
4249
}
4350
}

examples/change_wlan_password.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,17 @@
3535
/**
3636
* initialize the UniFi API connection class and log in to the controller
3737
*/
38-
$unifi_connection = new UniFi_API\Client($controlleruser, $controllerpassword, $controllerurl, $site_id, $controllerversion);
39-
$set_debug_mode = $unifi_connection->set_debug($debug);
40-
$loginresults = $unifi_connection->login();
41-
$results = $unifi_connection->set_wlansettings($wlan_id, $new_password);
38+
$unifi_connection = new UniFi_API\Client(
39+
$controlleruser,
40+
$controllerpassword,
41+
$controllerurl,
42+
$site_id,
43+
$controllerversion
44+
);
45+
46+
$set_debug_mode = $unifi_connection->set_debug($debug);
47+
$loginresults = $unifi_connection->login();
48+
$results = $unifi_connection->set_wlansettings($wlan_id, $new_password);
4249

4350
/**
4451
* provide feedback in json format

examples/create_site.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,16 @@
3030
/**
3131
* initialize the UniFi API connection class and log in to the controller and do our thing
3232
*/
33-
$unifi_connection = new UniFi_API\Client($controlleruser, $controllerpassword, $controllerurl, $site_id, $controllerversion);
34-
$loginresults = $unifi_connection->login();
35-
$results = $unifi_connection->create_site($description);
33+
$unifi_connection = new UniFi_API\Client(
34+
$controlleruser,
35+
$controllerpassword,
36+
$controllerurl,
37+
$site_id,
38+
$controllerversion
39+
);
40+
41+
$loginresults = $unifi_connection->login();
42+
$results = $unifi_connection->create_site($description);
3643

3744
/**
3845
* provide feedback in json format

examples/create_voucher.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,16 @@
3535
/**
3636
* initialize the UniFi API connection class and log in to the controller
3737
*/
38-
$unifi_connection = new UniFi_API\Client($controlleruser, $controllerpassword, $controllerurl, $site_id, $controllerversion);
39-
$set_debug_mode = $unifi_connection->set_debug($debug);
40-
$loginresults = $unifi_connection->login();
38+
$unifi_connection = new UniFi_API\Client(
39+
$controlleruser,
40+
$controllerpassword,
41+
$controllerurl,
42+
$site_id,
43+
$controllerversion
44+
);
45+
46+
$set_debug_mode = $unifi_connection->set_debug($debug);
47+
$loginresults = $unifi_connection->login();
4148

4249
/**
4350
* then we create the required number of vouchers with the requested expiration value

0 commit comments

Comments
 (0)