PHP code example of antonforwork / ivideon-php

1. Go to this page and download the library: Download antonforwork/ivideon-php library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

antonforwork / ivideon-php example snippets


$account = new Account('login_email', 'password', '.cache');
$api = new Api($account, new WebFlow());

$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