unifi-php-api/examples
malle-pietje c82481a28a API client class v1.1.62
- added several monthly stats methods: `stat_monthly_gateway()`, `stat_monthly_site()`, `stat_monthly_aps()`, `stat_monthly_user()`, thanks go to @Roel Janssens for spotting these MongoDB collections
- test for `object` or `resource` in `get_curl_resource()`, closes PR #82 submitted by @banakito
- applied change to comments in `example/modify_smartpower_pdu_outlet.php` based on a suggestion by @thesohoguy
- removed unnecessary variable from `list_apgroups()`, thanks go to Stephen Davies for reporting
- added an optional parameter $ap_group_ids to the `create_wlan()` function/method for UniFi controller versions 6.0.X and higher, thanks go to Stephen Davies for contributing
2020-12-10 14:52:39 +01:00
..
site_provisioning_example General code cleanup (replace tabs by spaces, etc.) 2018-03-24 10:46:42 +01:00
ap_scanning_state.php API client class v1.1.41 2019-04-29 17:35:09 +02:00
ap_upgrade_firmware.php API client class v1.1.43 2019-12-13 09:15:10 +01:00
auth_guest_basic.php API client class v1.1.42 2019-10-15 14:04:37 +02:00
auth_guest_with_note.php added example to change AC-IW port config 2018-03-24 09:28:25 +01:00
block_list.php API client class v1.1.51 2020-03-19 16:07:31 +01:00
change_super_mgmt.php clean up of example code based on feedback from scrutinizer-ci.com 2019-10-15 14:27:28 +02:00
change_wlan_password.php fixed typo in examples/change_wlan_password.php 2017-10-06 12:55:44 +02:00
config.template.php API client class v1.1.47 2020-02-06 08:52:49 +01:00
create_site.php minor bugs removed from two examples 2018-02-01 17:11:05 +01:00
create_voucher.php minor code cleanup and various changes: 2017-10-06 12:46:07 +02:00
delete_site.php minor bugs removed from two examples 2018-02-01 17:11:05 +01:00
disable_device.php Update disable_device.php 2017-10-20 09:25:59 +02:00
disable_switch_port.php API client class v1.1.58 2020-10-22 14:23:29 +02:00
execute_custom_api_request.php API client class v1.1.41 2019-04-29 17:35:09 +02:00
extend_guest_auth.php fixed minor syntax error/typo in an example 2019-10-15 14:41:16 +02:00
list_alarms.php
list_ap_connected_users.php General code cleanup (replace tabs by spaces, etc.) 2018-03-24 10:46:42 +01:00
list_connected_users.php API client class v1.1.43 2019-12-13 09:15:10 +01:00
list_site_health.php General code cleanup (replace tabs by spaces, etc.) 2018-03-24 10:46:42 +01:00
list_social_auth_details.php
list_user_stats.php added user/client device stats methods/functions: 2018-07-02 15:06:31 +02:00
modify_smartpower_pdu_outlet.php API client class v1.1.62 2020-12-10 14:52:39 +01:00
README.md API client class v1.1.37 2018-11-05 12:18:10 +01:00
reconnect_client.php API client class v1.1.44 2020-01-27 13:19:49 +01:00
test_connection.php API client class v1.1.49 2020-02-07 08:27:39 +01:00
toggle_led.php
unblock_list.php clean up of example code based on feedback from scrutinizer-ci.com 2019-10-15 14:27:28 +02:00
update_ac-iw_ports.php removed and added spaces, and changed brackets usage following PSR-2 guidelines 2018-10-02 13:16:48 +02:00
update_device_wlan_settings_5.5.X.php removed and added spaces, and changed brackets usage following PSR-2 guidelines 2018-10-02 13:16:48 +02:00
update_switch_poe-mode.php code cleanup and improvements in preparation of support for UniFi OS-based controllers 2020-02-04 07:41:43 +01:00

API client class usage examples

This directory contains some PHP code examples which demonstrate usage of the PHP API client class and can be used as a good starting point for your own custom code.

Usage

Copy the appropriate example file to your working directory together with a copy of the config.template.php file which should be renamed to config.php. Then update the contents of your new config.php with your controller details and credentials and modify the example file as required to fit your needs.

Also make sure to update the path for the composer autoloader file (vendor/autoload.php) or the file containing the Class itself (src/Client.php) in your require_once() statement as required.

Executing scripts from the CLI

Most of the included example scripts can be run from the CLI or shell as follows after the necessary credentials and parameters have been added or updated:

$ php list_site_health.php

NOTE: this does require the php-cli module to be installed

Contribute

If you would like to share your own example file(s), please open an issue and include your code there or else create a pull request.

Important Disclaimer

Use these examples at your own risk!