khicks / myq-php
此包已被弃用且不再维护。没有建议的替代包。
Chamberlain MyQ 的 PHP 封装器
v0.1.0
2019-02-02 01:45 UTC
Requires
- php: >=7.2
- ext-curl: *
This package is auto-updated.
Last update: 2024-01-22 00:08:11 UTC
README
Chamberlain MyQ 的 PHP 封装器。
安装
$ sudo apt-get install composer php php-curl $ composer require khicks/myq-php
使用示例
基础使用
<?php require_once('vendor/autoload.php'); $myq = new MyQ\MyQ($myq_username, $myq_password); $door = $myq->getGarageDoorDevices()[0]; // Get door state information. $door->getState()->getDescription(); // "closed" $door->getState()->getDeltaInt(); // 4924 $door->getState()->getDeltaStr(); // "1 hour, 22 minutes, 4 seconds" // Open and close door. $door->open(); sleep(20); $door->close(); // The security token is like a cookie that you obtain after logging in. // You should save this value if you want to use it for subsequent runs. $myq->getSecurityToken()->getValue(); // "5ff81c31-6725-40f5-81a2-dc352ad300dd"
使用之前的密钥令牌
如果只提供了用户名和密码,每次创建对象时,MyQ 都将执行额外的 API 调用来登录。如果您想使用之前获取的密钥令牌来创建 MyQ 对象,请将其传递到可选的第三个参数。如果令牌无效,MyQ-PHP 将自动尝试再次登录并使用新的密钥令牌。
<?php require_once('vendor/autoload.php'); $myq = new MyQ\MyQ($myq_username, $myq_password, $security_token); $door = $myq->getGarageDoorDevices()[0]; // ...