christianberkman/zte-mf286-api

ZTE MF286 4G路由器非官方API

0.3 2022-10-07 19:49 UTC

This package is auto-updated.

Last update: 2024-09-27 23:40:29 UTC


README

ZTE MF284 4G路由器API,可能也适用于相关型号

安装和使用

composer require christianberkman/zte-mf286-api
<?php
    $zteApi = new ZTEMF286\Api('192.168.1.1', '/path/to/cookie');
    $login = $zteApi->login('password'); // returns boolean

公共函数

constructor(string $routerIp, string $cookiePath = DIR)

构建类并设置路由器IP,可选的Cookie路径

setCookiePath(string $path)

检查路径是否可写,并在为真时设置Cookie路径。Cookie文件名为zte-cookie

login(string $routerPassword)

使用提供的密码登录路由器,返回布尔值。

getCmd(array $commands, bool $decode = true)

返回$commands中给出的参数(参见(get-commands.md)[https://github.com/christianberkman/zte-mf286-api/blob/main/get-commands.md])作为数组。将$decode设置为true将解码JSON响应为数组,false将返回字符串形式的响应。如果失败则返回null。

setCmd(string $command, array $postFields, bool $decode = true)

发送包括$postFields$command。将$decode设置为true将解码JSON响应为数组,false将返回字符串形式的响应。如果失败则返回null。

isWanConnected()

返回WAN是否连接,返回布尔值

connect()

尝试连接网络,返回布尔值

reconnect()

尝试断开连接,返回布尔值

restart()

尝试重启路由器,返回布尔值

dataUsage()

以数组形式报告数据使用情况,如果失败则返回false

[rx] => Array   
    [bytes] => 116867051568
    [GiB] => 108.84
[tx] => Array
    [bytes] => 17771215964
    [GiB] => 16.55
[total] => Array
    [bytes] => 134638267532
    [GiB] => 125.39

realtime()

返回实时rx和tx字节数/秒,KiB/s,MiB/s。通常调制解调器接口中的上传/下载监控器返回0

    [rx_mib] => 0
    [rx_kib] => 0.34
    [rx_bytes] => 348
    [tx_mib] => 0
    [tx_kib] => 0.18
    [tx_bytes] => 188

connectedDevices()

返回连接设备数组

[wifi]
    [0]
        [mac_addr] => 1C:F2:9A:56:09:73
        [hostname] => Google-Nest-Mini
        [ip_addr] => 192.168.1.161
        [addr_type] => 2
        [ssid_index] => 0
    [..]
[lan]
    [..]
[all]
    [..] // wifi and lan combined