Compare commits

..

4 Commits

Author SHA1 Message Date
malle-pietje
746a29fbcf code optimization, improved parameter validation and debug messages
- removed repetitive code (json_decode and $this>baseurl)
- added capture of JSON decoding errors when debug = true
- use intval() on function/method parameters which must be an integer
- further parameter validation/checks
2017-10-12 17:21:50 +02:00
malle-pietje
6fd7e6e598 added new functions for 5-minutes stats and minor code cleanup
- stat_5minutes_site()
- stat_5minutes_aps()
- added optional parameter to list_dashboard() to allow fetching of 5minutes stats
2017-10-10 09:37:29 +02:00
malle-pietje
4611dbb28c applied small formatting change to README 2017-10-06 12:59:20 +02:00
malle-pietje
cc486f652d fixed typo in examples/change_wlan_password.php 2017-10-06 12:55:44 +02:00
3 changed files with 481 additions and 332 deletions

View File

@@ -1,8 +1,8 @@
## UniFi controller API client class
This PHP class 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.5.20 has been confirmed to work). It is an independent version of the class which is used in the API browser tool [here](https://github.com/Art-of-WiFi/UniFi-API-browser).
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 the API browser tool [here](https://github.com/Art-of-WiFi/UniFi-API-browser).
The class is now also installable through composer/[packagist](https://packagist.org/packages/art-of-wifi/unifi-api-client) for easy inclusion in your projects.
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.
### Donations
@@ -12,7 +12,7 @@ If you'd like to support further development of this PHP API client class, pleas
## Methods and functions supported
This class currently supports the following functions/methods to get/set data through the UniFi controller API:
The class currently supports the following functions/methods to get/post/put/delete data through the UniFi controller API:
- login()
- logout()
- adopt_device()
@@ -88,10 +88,12 @@ This class currently supports the following functions/methods to get/set data th
- stat_allusers()
- stat_auths()
- stat_client()
- stat_daily_aps()
- stat_daily_site()
- stat_5minutes_aps() (supported on controller version 5.5.* and higher)
- stat_hourly_aps()
- stat_daily_aps()
- stat_5minutes_site() (supported on controller version 5.5.* and higher)
- stat_hourly_site()
- stat_daily_site()
- stat_payment()
- stat_sessions()
- stat_sites()
@@ -113,7 +115,7 @@ Internal functions, getters/setters:
- get_last_results_raw()
- get_last_error_message()
Please refer to the source code for more details on each function/method and it's parameters.
Please refer to the source code for more details on each function/method and their parameters.
## Requirements
@@ -185,7 +187,7 @@ Please refer to the `examples/` directory for some more detailed examples which
### IMPORTANT NOTES:
In the example above, the last parameter (`true`, without quotes) that is passed to the constructor enables validation of the controller's SSL certificate which is *disabled* by default.
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.
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.
---
@@ -209,7 +211,7 @@ If you would like to contribute code (improvements), please open an issue and in
This class is largely based on the work done by the following developers:
- domwo: http://community.ubnt.com/t5/UniFi-Wireless/little-php-class-for-unifi-api/m-p/603051
- fbagnol: https://github.com/fbagnol/class.unifi.php
- and the API as published by Ubiquiti: https://www.ubnt.com/downloads/unifi/5.5.20/unifi_sh_api
- and the API as published by Ubiquiti: https://dl.ubnt.com/unifi/5.6.18-8261dc5066/unifi_sh_api
## Important Disclaimer

View File

@@ -37,9 +37,10 @@ $new_password = '<new password goes here>';
*/
$unifi_connection = new UniFi_API\Client($controlleruser, $controllerpassword, $controllerurl, $site_id, $controllerversion);
$set_debug_mode = $unifi_connection->set_debug($debug);
$loginresults = $unifi_connection->set_wlansettings($wlan_id, $new_password);
$loginresults = $unifi_connection->login();
$results = $unifi_connection->set_wlansettings($wlan_id, $new_password);
/**
* provide feedback in json format
*/
echo json_encode($loginresults, JSON_PRETTY_PRINT);
echo json_encode($results, JSON_PRETTY_PRINT);

File diff suppressed because it is too large Load Diff