antonforwork / ivideon-php
IVideon
v1.0.7
2023-01-19 10:39 UTC
Requires
- php: >=7.2
- guzzlehttp/guzzle: >=6
- lazyjsonmapper/lazyjsonmapper: ^1.6
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.16
README
This is PHP Library which allow work with IVideon API
Instalation
composer require antonforwork/ivideon-php
$account = new Account('login_email', 'password', '.cache');
$api = new Api($account, new WebFlow());
Please use .cache file.
In first run library will try to login with your email and password and store your access_token, userid and userApiUrl in cache file
all next runs will use these data.
If cacheFile not set api will try login in every run (slowly)
Print all server and cameras
$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
/* 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();
Get all exports
$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;
};
Delete export file
$api->camera->deleteExport($exportId); // bool