antonforwork/ivideon-php

v1.0.7 2023-01-19 10:39 UTC

This package is auto-updated.

Last update: 2024-09-19 14:21:23 UTC


README

compatible

这是一个PHP库,允许您使用IVideon API进行操作

安装

composer require antonforwork/ivideon-php
$account = new Account('login_email', 'password', '.cache');
$api = new Api($account, new WebFlow());

请使用.cache文件。

首次运行时,库将尝试使用您的电子邮件和密码登录,并将您的access_tokenuseriduserApiUrl存储在缓存文件中,后续运行将使用这些数据。

如果没有设置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