双面 / ivideon-php
IVideon
v1.0.1
2024-02-20 14:46 UTC
Requires
- php: >=8.0
- guzzlehttp/guzzle: ^7.8.1
- lazyjsonmapper/lazyjsonmapper: ^v2.0.1
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.16
This package is not auto-updated.
Last update: 2024-09-18 15:56:42 UTC
README
这是一个PHP库,允许您与IVideon API进行交互。
安装
composer require two-faces/ivideon-php
$account = new Account('login_email', 'password', '.cache'); $api = new Api($account, new WebFlow());
请使用.cache
文件。
首次运行时,库将尝试使用您的电子邮件和密码登录,并将您的access_token
、userid
和userApiUrl
存储在缓存文件中。之后的运行将使用这些数据。
如果未设置cacheFile
,则API将在每次运行时尝试登录(较慢)。
打印所有服务器和摄像机
$servers = $api->servers->getServers(); foreach ($servers as $server) { echo $server->getTimezone(); // Important! see below foreach ($server->getCameras() as $camera) { echo $camera->getId() . PHP_EOL; } }
创建导出请求
/* Create export request * Please note that $start, $end is unix timestamp values * Please verify that $start, $end in your server timezone * * Important! * IVideon not allow to export "empty" videos, when nobody in all period * ExportRequestFailedException will be thrown */ $exportResult = $api->camera->exportMp4($cameraId, $start, $end); $exportId = $exportResult->getId();
获取所有导出
$exports = $api->camera->getExports(); foreach ($exports as $export) { echo $export->getId() . ' = ' . $export->getStatus(); if ($export->getStatus() == \IVideon\Responses\ExportResult::EXPORT_STATUS_READY) { echo ' = ' . $export->getVideoUrl(); } echo PHP_EOL; };
删除导出文件
$api->camera->deleteExport($exportId); // bool