From 09607dba0de8010b2a276fb5221c1ddcf528b0d7 Mon Sep 17 00:00:00 2001 From: malle-pietje Date: Wed, 23 Mar 2016 19:02:23 +0100 Subject: [PATCH] added list_usergroups to API class and to API browser version 1.0.1 --- index.php | 7 ++++++- phpapi/class.unifi.php | 23 ++++++++++++++++++++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/index.php b/index.php index 24ec42c..5eecadb 100644 --- a/index.php +++ b/index.php @@ -14,7 +14,7 @@ Ubiquiti Community forums for this: https://community.ubnt.com/t5/UniFi-Wireless/Unifi-API-browser-tool-released/m-p/1392651 -VERSION: 1.0 +VERSION: 1.0.1 ------------------------------------------------------------------------------------ @@ -228,6 +228,10 @@ $selection = 'list guests'; $data = $unifidata->list_guests(); break; + case 'list_usergroups': + $selection = 'list usergroups'; + $data = $unifidata->list_usergroups(); + break; case 'stat_hourly_site': $selection = 'hourly site stats'; $data = $unifidata->stat_hourly_site(); @@ -477,6 +481,7 @@ function to print the output
  • list online clients
  • list guests
  • list users
  • +
  • list user groups
  • stat all users
  • stat authorisations
  • diff --git a/phpapi/class.unifi.php b/phpapi/class.unifi.php index a2bf627..54819b5 100644 --- a/phpapi/class.unifi.php +++ b/phpapi/class.unifi.php @@ -9,7 +9,7 @@ and the API as published by Ubiquiti: https://dl.ubnt.com/unifi/4.7.6/unifi_sh_api -VERSION: 1.0 +VERSION: 1.0.1 NOTE: this Class will only work with Unifi Controller versions 4.x. There are no checks to prevent you from @@ -435,6 +435,27 @@ public function list_clients() { return $return; } + /* + list user groups + returns an array of user group objects + */ + public function list_usergroups() { + if (!$this->is_loggedin) return false; + $return = array(); + $json = json_encode(array()); + $content_decoded = json_decode($this->exec_curl($this->baseurl.'/api/s/'.$this->site.'/list/usergroup','json='.$json)); + if (isset($content_decoded->meta->rc)) { + if ($content_decoded->meta->rc == 'ok') { + if (is_array($content_decoded->data)) { + foreach ($content_decoded->data as $usergroup) { + $return[]= $usergroup; + } + } + } + } + return $return; + } + /* list health metrics returns an array of health metric objects