tomb1n0 / unifiapi
此包的最新版本(0.1.1)没有提供许可证信息。
0.1.1
2021-03-24 20:01 UTC
Requires
This package is auto-updated.
Last update: 2024-09-19 21:44:34 UTC
README
此包旨在简化与Unifi控制器的协作。
安装
确保您已安装 composer,然后在项目的根目录下运行 composer require tomb1n0/unifiapi
。
请确保在您的代码中包含composer自动加载文件。
<?php require_once('vendor/autoload.php'); // replace these with your own details. define('UNIFI_URL', 'https://unifi.yourdomain.co.uk:8443'); define('UNIFI_SITE', 'Southampton'); define('UNIFI_USERNAME', 'admin'); define('UNIFI_PASSWORD', 'unifipassword'); // get an instance of the api $api = new UnifiAPI\API(UNIFI_URL, UNIFI_SITE, UNIFI_USERNAME, UNIFI_PASSWORD); // get a controller object $controller = $api->controller();
示例
获取控制器健康信息(在线AP数量等)
$health = $controller->health(); $wlan_health = $health[0]; $wan_health = $health[1]; $www_health = $health[2]; $lan_health = $health[3]; $vpn_health = $health[4]; echo 'Num Adopted APs: ' . $wlan_health['num_adopted'];
获取任何未采用的WAP
// get any unadopted WAPs $devices = $controller->unadopted_devices(); // Adopt each of them foreach ($devices as $device) { $device->adopt(); }