From ab38e6f7ade478d1723fb31092528c2f4ca0493b Mon Sep 17 00:00:00 2001 From: malle-pietje Date: Thu, 7 Sep 2017 12:27:20 +0200 Subject: [PATCH] updated README --- README.md | 70 ++++++++++++++++++++++++++++++++++++-------------- src/Client.php | 1 + 2 files changed, 52 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 787bb07..89552a8 100755 --- a/README.md +++ b/README.md @@ -1,13 +1,14 @@ ## 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 (version 5.5.20 has been confirmed to work) are supported. +This PHP class provides access to Ubiquiti's **UniFi Controller API**. Versions 4.x.x and 5.x.x of the UniFi Controller software (version 5.5.20 has been confirmed to work) are supported. 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). ### Donations + 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. [![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=M7TVNVX3Z44VN) -### Methods and functions supported +## Methods and functions supported This class currently supports the following functions/methods to get/set data through the UniFi controller API: - login() @@ -107,24 +108,48 @@ Internal functions, getters/setters: Please refer to the source code for more details on each function/method and it's parameters. -### Credits +## Credits + 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 -### Requirements +## Requirements + - a web server with PHP and cURL modules installed (tested on apache2 with PHP Version 5.6.1 and cURL 7.42.1) - network connectivity between this web server and the server and port (normally port 8443) where the UniFi controller is running -### Install -Simply execute this command from your project directory: +## Installation ## -``` -$ composer require art-of-wifi/unifi-api-client +You can use **Composer** or simply **Download the Release** + +### Composer + +The preferred method is via [composer](https://getcomposer.org). Follow the [installation instructions](https://getcomposer.org/doc/00-intro.md) if you do not already have composer installed. + +Once composer is installed, simply execute this command from your project directory: + +```sh +composer require art-of-wifi/unifi-api-client ``` -### Example usage +Finally, be sure to include the autoloader in your code: + +```php +require_once 'vendor/autoload.php'; +``` + +### Download the Release + +If you prefer not to use composer, you can simply download the package, uncompress the zip file, then in your code include the file containing the class like so: + +```php +require_once('path/to/src/Client.php'); +``` + +## Example usage + A basic example how to use the class: ```php @@ -133,7 +158,7 @@ A basic example how to use the class: /** * load the class using the composer autoloader */ -require "vendor/autoload.php"; +require 'vendor/autoload.php'; /** * initialize the Unifi API connection class, log in to the controller and request the alarms collection @@ -148,15 +173,22 @@ $results = $unifi_connection->list_alarms(); // returns the alarms in a Please refer to the `examples` directory for some more detailed examples which you can use as a starting point for your own PHP code. ->**NOTE:** -> ->$site_id is the 8 character short site "name" which is visible in the URL when managing the site in the UniFi controller: -> ->``` ->https://:8443/manage/site/jl3z2shm/dashboard ->``` -> ->Here `jl3z2shm` is the value required for $site_id. +### NOTE: + +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: + +`https://:8443/manage/site/jl3z2shm/dashboard` + +In this case, `jl3z2shm` is the value required for $site_id. + +## Need help or have suggestions? + +There is still work to be done to add functionality and improve the usability of this class, so all suggestions/comments are welcome. Please use the github [issue](https://github.com/Art-of-WiFi/UniFi-API-client/issues) list or the Ubiquiti Community forums (https://community.ubnt.com/t5/UniFi-Wireless/PHP-class-to-access-the-UniFi-controller-API-updates-and/td-p/1512870) to share your ideas. + +## Contribute + +If you would like to contribute code (improvements), please open an issue and include your code there or else create a pull request. ## Important Disclaimer + Many of these functions are not officially supported by UBNT and as such, may not be supported in future versions of the UniFi controller API. \ No newline at end of file diff --git a/src/Client.php b/src/Client.php index ad11d6c..50c191b 100755 --- a/src/Client.php +++ b/src/Client.php @@ -13,6 +13,7 @@ * This source file is subject to the MIT license that is bundled * with this package in the file LICENSE.md */ + namespace UniFi_API; class Client