mirror of
https://github.com/Art-of-WiFi/UniFi-API-client.git
synced 2024-11-24 11:10:02 +01:00
fixed bug caused by typo with "if (in_array()..."
This commit is contained in:
parent
449baa70a3
commit
e3e70cce72
50
examples/disable_device.php
Executable file
50
examples/disable_device.php
Executable file
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP API usage example
|
||||
*
|
||||
* contributed by: Art of WiFi
|
||||
* description: example basic PHP script to disable/enable a device, returns true upon success
|
||||
*/
|
||||
|
||||
/**
|
||||
* using the composer autoloader
|
||||
*/
|
||||
require_once('vendor/autoload.php');
|
||||
|
||||
/**
|
||||
* include the config file (place your credentials etc. there if not already present)
|
||||
* see the config.template.php file for an example
|
||||
*/
|
||||
require_once('config.php');
|
||||
|
||||
/**
|
||||
* the 24 character id of the device to disable/enable
|
||||
*/
|
||||
$device_id = '<enter the id of your device here>';
|
||||
|
||||
/**
|
||||
* the site to which the device belongs
|
||||
*/
|
||||
$site_id = '<enter your site id here>';
|
||||
|
||||
/**
|
||||
* initialize the UniFi API connection class and log in to the controller
|
||||
*/
|
||||
$unifi_connection = new UniFi_API\Client($controlleruser, $controllerpassword, $controllerurl, $site_id, $controllerversion);
|
||||
$set_debug_mode = $unifi_connection->set_debug($debug);
|
||||
$loginresults = $unifi_connection->login();
|
||||
|
||||
/**
|
||||
* then we disable the device
|
||||
*/
|
||||
$disable_result = $unifi_connection->disable_ap($device_id, true);
|
||||
|
||||
/**
|
||||
* or we enable the device, uncomment as neccesary (then also comment the previous call)
|
||||
*/
|
||||
//$disable_result = $unifi_connection->disable_ap($device_id, false);
|
||||
|
||||
/**
|
||||
* provide feedback (the newly created voucher code, without the dash) in json format
|
||||
*/
|
||||
echo json_encode($disable_result, JSON_PRETTY_PRINT);
|
@ -1275,7 +1275,7 @@ class Client
|
||||
*/
|
||||
public function set_ap_wlangroup($wlantype_id, $device_id, $wlangroup_id) {
|
||||
if (!$this->is_loggedin) return false;
|
||||
if (in_array($wlantype_id, ['ng', 'na'])) return false;
|
||||
if (!in_array($wlantype_id, ['ng', 'na'])) return false;
|
||||
$json = json_encode(['wlan_overrides' => [],'wlangroup_id_'.$wlantype_id => $wlangroup_id]);
|
||||
$response = $this->exec_curl('/api/s/'.$this->site.'/upd/device/'.trim($device_id),'json='.$json);
|
||||
return $this->process_response_boolean($response);
|
||||
@ -1550,7 +1550,7 @@ class Client
|
||||
*/
|
||||
public function set_wlan_mac_filter($wlan_id, $mac_filter_policy, $mac_filter_enabled, array $macs)
|
||||
{
|
||||
if (in_array($mac_filter_policy, ['allow', 'deny'])) return false;
|
||||
if (!in_array($mac_filter_policy, ['allow', 'deny'])) return false;
|
||||
$payload = (object)[];
|
||||
$payload->mac_filter_enabled = (bool)$mac_filter_enabled;
|
||||
$payload->mac_filter_policy = $mac_filter_policy;
|
||||
|
Loading…
Reference in New Issue
Block a user