Skip to content

Commit c6222d2

Browse files
committed
include API client class 1.1.25
add support for list_country_codes()
1 parent e44ca42 commit c6222d2

23 files changed

+1332
-106
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ This tool is for browsing data that is exposed through Ubiquiti's UniFi Controll
1111
1212
It comes bundled with a **PHP class for access to the UniFi Controller API**, which supports [more API endpoints](https://github.com/Art-of-WiFi/UniFi-API-client#methods-and-functions-supported) than the UniFi API browser tool does.
1313
14-
If you plan to create your own PHP code levering the UniFi controller API, it is recommended to use the standalone version of the API client class which can be found here: https://github.com/Art-of-WiFi/UniFi-API-client
14+
If you plan to create your own PHP code leveraging the UniFi controller API, it is recommended to use the standalone version of the API client class which can be found here: https://github.com/Art-of-WiFi/UniFi-API-client
1515
1616
You will find examples and detailed instructions there.
1717
1818
Please keep the following in mind:
1919
- the API Browser tool doesn't support all available data collections/API endpoints, see the list below of those that are currently supported
20-
- currently, versions 4.x.x and 5.x.x of the UniFi Controller software are supported (version 5.6.18 has been confirmed to work)
20+
- currently, versions 4.x.x and 5.x.x of the UniFi Controller software are supported (version 5.7.20 has been confirmed to work)
2121
- there is still work to be done to add/improve functionality and usability of this tool so suggestions/comments are welcome. Please use the github [issue](https://github.com/Art-of-WiFi/UniFi-API-browser/issues) list or the Ubiquiti Community forums (https://community.ubnt.com/t5/UniFi-Wireless/UniFi-API-browser-tool-released/m-p/1392651) to share your ideas/questions.
2222
- please read the Security Notice below before installing this tool!
2323
@@ -81,6 +81,7 @@ The UniFi API browser tool offers the following features:
8181
- list current channels
8282
- list DPI stats
8383
- dynamic DNS configuration
84+
- list country codes
8485
- list Radius accounts (supported on controller version 5.5.19 and higher)
8586
- Messages
8687
- list events

composer.lock

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config.template.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,4 @@
5656
// bootstrap, cerulean, cosmo, cyborg, darkly, flatly, journal, lumen, paper
5757
// readable, sandstone, simplex, slate, spacelab, superhero, united, yeti
5858

59-
$debug = false; // set to true (without quotes) to enable debug output to the browser and the PHP error log
60-
?>
59+
$debug = false; // set to true (without quotes) to enable debug output to the browser and the PHP error log

index.php

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@
99
* - not all data collections/API endpoints are supported (yet), see the list of
1010
* the currently supported data collections/API endpoints in the README.md file
1111
* - this tool currently supports versions 4.x and 5.x of the UniFi Controller software
12-
*
13-
* VERSION: 1.0.26
14-
*
1512
* ------------------------------------------------------------------------------------
1613
*
1714
* Copyright (c) 2017, Art of WiFi
@@ -20,7 +17,7 @@
2017
* with this package in the file LICENSE.md
2118
*
2219
*/
23-
define('API_BROWSER_VERSION', '1.0.26');
20+
define('API_BROWSER_VERSION', '1.0.27');
2421
define('API_CLASS_VERSION', get_client_version());
2522

2623
/**
@@ -29,10 +26,13 @@
2926
* - if not, stop and display an error message
3027
*/
3128
if (function_exists('curl_version')) {
32-
$curl_info = curl_version();
33-
$curl_version = $curl_info['version'];
29+
$curl_info = curl_version();
30+
$curl_version = $curl_info['version'];
31+
$openssl_version = $curl_info['ssl_version'];
3432
} else {
3533
exit('The <b>PHP curl</b> module is not installed! Please correct this before you proceed!<br>');
34+
$curl_version = 'unavailable';
35+
$openssl_version = 'unavailable';
3636
}
3737

3838
/**
@@ -491,6 +491,10 @@
491491
$selection = 'list radius profiles';
492492
$data = $unifidata->list_radius_profiles();
493493
break;
494+
case 'list_country_codes':
495+
$selection = 'list country codes';
496+
$data = $unifidata->list_country_codes();
497+
break;
494498
default:
495499
break;
496500
}
@@ -837,6 +841,8 @@ function get_client_version()
837841
<li id="list_portconf"><a href="?action=list_portconf">list port configuration</a></li>
838842
<li id="list_portforwarding"><a href="?action=list_portforwarding">list port forwarding rules</a></li>
839843
<li id="list_dynamicdns"><a href="?action=list_dynamicdns">dynamic DNS configuration</a></li>
844+
<li role="separator" class="divider"></li>
845+
<li id="list_country_codes"><a href="?action=list_country_codes">list country codes</a></li>
840846
<!-- Radius-related collections, only to be displayed when we have detected a capable controller version -->
841847
<?php if ($detected_controller_version != 'undetected' && version_compare($detected_controller_version, '5.5.19') >= 0) { ?>
842848
<li role="separator" class="divider"></li>
@@ -1001,6 +1007,8 @@ function get_client_version()
10011007
<dd><span id="span_memory_used" class="label label-primary"></span></dd>
10021008
<dt>cURL version</dt>
10031009
<dd><span id="span_curl_version" class="label label-primary"></span></dd>
1010+
<dt>OpenSSL version</dt>
1011+
<dd><span id="span_openssl_version" class="label label-primary"></span></dd>
10041012
<dt>operating system</dt>
10051013
<dd><span id="span_os_version" class="label label-primary"></span></dd>
10061014
</dl>
@@ -1045,6 +1053,7 @@ function get_client_version()
10451053
var memory_limit = '<?php echo (ini_get('memory_limit')) ?>';
10461054
var memory_used = '<?php echo round(memory_get_peak_usage(false)/1024/1024, 2) . 'M' ?>';
10471055
var curl_version = '<?php echo $curl_version ?>';
1056+
var openssl_version = '<?php echo $openssl_version ?>';
10481057
var os_version = '<?php echo (php_uname('s') . ' ' . php_uname('r')) ?>';
10491058
var api_browser_version = '<?php echo API_BROWSER_VERSION ?>';
10501059
var api_class_version = '<?php echo API_CLASS_VERSION ?>';
@@ -1057,24 +1066,22 @@ function get_client_version()
10571066
*/
10581067
$('#alert_placeholder').html(alert_message);
10591068
$('#alert_placeholder').fadeIn(1000);
1069+
10601070
$('#span_site_id').html(site_id);
10611071
$('#span_site_name').html(site_name);
10621072
$('#span_output_format').html(output_format);
10631073
$('#span_selection').html(selection);
10641074
$('#span_objects_count').html(objects_count);
1065-
10661075
$('#span_elapsed_time').html('total elapsed time: ' + timing_total_time + ' seconds');
10671076

10681077
$('#timing_login_perc').attr('aria-valuenow', timing_login_perc);
10691078
$('#timing_login_perc').css('width', timing_login_perc + '%');
10701079
$('#timing_login_perc').attr('data-original-title', time_after_login + ' seconds');
10711080
$('#timing_login_perc').html('API login time');
1072-
10731081
$('#timing_load_perc').attr('aria-valuenow', timing_load_perc);
10741082
$('#timing_load_perc').css('width', timing_load_perc + '%');
10751083
$('#timing_load_perc').attr('data-original-title', time_for_load + ' seconds');
10761084
$('#timing_load_perc').html('data load time');
1077-
10781085
$('#timing_remain_perc').attr('aria-valuenow', timing_remain_perc);
10791086
$('#timing_remain_perc').css('width', timing_remain_perc + '%');
10801087
$('#timing_remain_perc').attr('data-original-title', 'PHP overhead: ' + timing_remain_perc + '%');
@@ -1087,6 +1094,7 @@ function get_client_version()
10871094
$('#span_controller_version').html(controller_version);
10881095
$('#span_php_version').html(php_version);
10891096
$('#span_curl_version').html(curl_version);
1097+
$('#span_openssl_version').html(openssl_version);
10901098
$('#span_os_version').html(os_version);
10911099
$('#span_memory_limit').html(memory_limit);
10921100
$('#span_memory_used').html(memory_used);

vendor/art-of-wifi/unifi-api-client/README.md

Lines changed: 41 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,17 @@
1-
## UniFi controller API client class
1+
## UniFi Controller API client class
22

3-
A PHP class which provides access to Ubiquiti's **UniFi Controller API**. Versions 4.x.x and 5.x.x of the UniFi Controller software are supported (version 5.6.18 has been confirmed to work). It's a standalone version of the class which is used in our API browser tool [here](https://github.com/Art-of-WiFi/UniFi-API-browser).
3+
A PHP class which provides access to Ubiquiti's **UniFi Controller API**, versions 4.x.x and 5.x.x of the UniFi Controller software are supported (version 5.6.29 has been confirmed to work). It's a standalone version of the class which is used in our API browser tool which can be found [here](https://github.com/Art-of-WiFi/UniFi-API-browser).
44

5-
This class can now also be installed using composer/[packagist](https://packagist.org/packages/art-of-wifi/unifi-api-client) for easy inclusion in your projects.
6-
7-
### Donations
8-
9-
If you'd like to support further development of this PHP API client class, please use the PayPal donate button below. All donations go to the project maintainer.
10-
11-
[![Donate](https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=M7TVNVX3Z44VN)
5+
This class can be installed using composer/[packagist](https://packagist.org/packages/art-of-wifi/unifi-api-client) for easy inclusion in your projects.
126

137
## Methods and functions supported
148

15-
The class currently supports the following functions/methods to get/post/put/delete data through the UniFi controller API:
9+
The class currently supports the following functions/methods to get/post/put/delete data through the UniFi Controller API:
10+
1611
- login()
1712
- logout()
1813
- adopt_device()
14+
- archive_alarm()
1915
- authorize_guest()
2016
- block_sta()
2117
- count_alarms()
@@ -26,6 +22,7 @@ The class currently supports the following functions/methods to get/post/put/del
2622
- create_usergroup()
2723
- create_voucher()
2824
- create_wlan()
25+
- delete_device()
2926
- delete_network()
3027
- delete_radius_account()
3128
- delete_site()
@@ -36,9 +33,11 @@ The class currently supports the following functions/methods to get/post/put/del
3633
- extend_guest_validity()
3734
- led_override()
3835
- list_admins()
36+
- list_all_admins()
3937
- list_alarms()
4038
- list_aps() (deprecated but still available as alias)
4139
- list_clients()
40+
- list_country_codes()
4241
- list_current_channels()
4342
- list_dashboard()
4443
- list_devices()
@@ -66,6 +65,7 @@ The class currently supports the following functions/methods to get/post/put/del
6665
- list_wlan_groups()
6766
- list_wlanconf()
6867
- locate_ap()
68+
- move_device()
6969
- power_cycle_switch_port()
7070
- reconnect_sta()
7171
- rename_ap()
@@ -74,9 +74,18 @@ The class currently supports the following functions/methods to get/post/put/del
7474
- set_ap_radiosettings()
7575
- set_device_settings_base()
7676
- set_guestlogin_settings()
77+
- set_guestlogin_settings_base()
7778
- set_locate_ap() (deprecated but still available as alias)
7879
- set_networksettings_base()
7980
- set_radius_account_base()
81+
- set_site_connectivity()
82+
- set_site_country()
83+
- set_site_guest_access()
84+
- set_site_locale()
85+
- set_site_mgmt()
86+
- set_site_name()
87+
- set_site_ntp()
88+
- set_site_snmp()
8089
- set_sta_name()
8190
- set_sta_note()
8291
- set_usergroup()
@@ -111,24 +120,25 @@ The class currently supports the following functions/methods to get/post/put/del
111120
- upgrade_device_external()
112121

113122
Internal functions, getters/setters:
123+
114124
- set_debug()
115-
- set_site()
125+
- get_debug()
116126
- set_site()
117127
- get_site()
118128
- get_cookie() (renamed from getcookie())
119129
- get_last_results_raw()
120130
- get_last_error_message()
121131

122-
Please refer to the source code for more details on each function/method and their parameters.
132+
Please refer to the source code for more details on the functions/methods and their parameters.
123133

124134
## Requirements
125135

126136
- a web server with PHP and cURL modules installed (tested on apache2 with PHP Version 5.6.1 and cURL 7.42.1)
127-
- network connectivity between this web server and the server and port (normally TCP port 8443) where the UniFi controller is running
137+
- network connectivity between this web server and the server and port (normally TCP port 8443) where the UniFi Controller is running
128138

129139
## Installation ##
130140

131-
You can use **Composer**, **Git** or simply **Download the Release** to install the API client class.
141+
You can use [Composer](#composer), [Git](#git) or simply [Download the Release](#download-the-release) to install the API client class.
132142

133143
### Composer
134144

@@ -138,6 +148,16 @@ Once composer is installed, simply execute this command from the shell in your p
138148

139149
```sh
140150
composer require art-of-wifi/unifi-api-client
151+
```
152+
153+
Or you can manually add the package to your composer.json file:
154+
155+
```javascript
156+
{
157+
"require": {
158+
"art-of-wifi/unifi-api-client": "^1.1"
159+
}
160+
}
141161
```
142162

143163
Finally, be sure to include the autoloader in your code:
@@ -189,18 +209,15 @@ $results = $unifi_connection->list_alarms(); // returns a PHP array con
189209

190210
Please refer to the `examples/` directory for some more detailed examples which you can use as a starting point for your own PHP code.
191211

192-
### IMPORTANT NOTES:
193-
194-
In the example above, the last parameter (`true`) that is passed to the constructor, enables validation of the controller's SSL certificate which is otherwise **disabled** by default.
195-
It is highly recommended to enable this feature in production environments where you have a valid SSL cert installed on the UniFi controller, and which is associated with the FQDN of the server as used in the `controller_url` parameter. This option was added with API client version 1.1.16.
212+
#### IMPORTANT NOTES:
196213

197-
---
214+
1. The last parameter (`true`) that is passed to the constructor, enables validation of the controller's SSL certificate which is otherwise **disabled** by default. It is highly recommended to enable this feature in production environments where you have a valid SSL cert installed on the UniFi Controller, and which is associated with the FQDN of the server as used in the `controller_url` parameter. This option was added with API client version 1.1.16.
198215

199-
In the example above, `$site_id` is the 8 character short site "name" which is visible in the URL when managing the site in the UniFi controller:
216+
2. In the example above, `$site_id` is the 8 character short site "name" which is visible in the URL when managing the site in the UniFi Controller:
200217

201-
`https://<controller IP address or FQDN>:8443/manage/site/jl3z2shm/dashboard`
218+
`https://<controller IP address or FQDN>:8443/manage/site/jl3z2shm/dashboard`
202219

203-
In this case, `jl3z2shm` is the value required for $site_id.
220+
In this case, `jl3z2shm` is the value required for $site_id.
204221

205222
## Need help or have suggestions?
206223

@@ -212,11 +229,11 @@ If you would like to contribute code (improvements), please open an issue and in
212229

213230
## Credits
214231

215-
This class is largely based on the work done by the following developers:
232+
This class is based on the work done by the following developers:
216233
- domwo: http://community.ubnt.com/t5/UniFi-Wireless/little-php-class-for-unifi-api/m-p/603051
217234
- fbagnol: https://github.com/fbagnol/class.unifi.php
218235
- and the API as published by Ubiquiti: https://dl.ubnt.com/unifi/5.6.18-8261dc5066/unifi_sh_api
219236

220237
## Important Disclaimer
221238

222-
Many of the functions in this API client class are not officially supported by UBNT and as such, may not be supported in future versions of the UniFi controller API.
239+
Many of the functions in this API client class are not officially supported by UBNT and as such, may not be supported in future versions of the UniFi Controller API.

vendor/art-of-wifi/unifi-api-client/examples/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ If you would like to share your own example file(s), please open an issue and in
1212

1313
## Important Disclaimer
1414

15-
Use these examples at your own risk!
15+
Use these examples at your own risk!
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
/**
3+
* PHP API usage example
4+
*
5+
* contributed by: @4oo4
6+
* description: example script to check and upgrade device firmware (can be scheduled with systemd/cron)
7+
* to the most current version
8+
*/
9+
require_once('vendor/autoload.php');
10+
require_once('config.php');
11+
12+
/**
13+
* site id of the AP to update
14+
*/
15+
$site_id = '<enter your site id here>';
16+
17+
/**
18+
* device MAC address formatted with colons, e.g. 'de:ad:be:ef:01:23'
19+
*/
20+
$device_mac = '<enter MAC address of device to update>';
21+
22+
/**
23+
* initialize the UniFi API connection class, log in to the controller
24+
* (this example assumes you have already assigned the correct values in config.php to the variables used)
25+
*/
26+
$unifi_connection = new UniFi_API\Client($controlleruser, $controllerpassword, $controllerurl, $site_id, $controllerversion, false);
27+
$login = $unifi_connection->login();
28+
29+
/**
30+
* Run the actual upgrade
31+
*/
32+
$results = $unifi_connection->upgrade_device($device_mac);
33+
34+
/**
35+
* provide feedback in json format from $response given by upgrade_device();
36+
*/
37+
echo json_encode($results, JSON_PRETTY_PRINT);

vendor/art-of-wifi/unifi-api-client/examples/auth_guest_with_note.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
* PHP API usage example
44
*
55
* contributed by: Art of WiFi
6-
* description: example basic PHP script to auth a guest device and attach a note to it
6+
* description: example basic PHP script to auth a guest device and attach a note to it,
7+
* this requires the device to be connected to the WLAN/LAN at moment of
8+
* authorization
79
*/
810

911
/**

vendor/art-of-wifi/unifi-api-client/examples/config.template.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@
2121
/**
2222
* set to true (without quotes) to enable debug output to the browser and the PHP error log
2323
*/
24-
$debug = false;
24+
$debug = false;

0 commit comments

Comments
 (0)