<pre>
<?php
$user = "<username>";
$password = "<password>";
$cameraid = "<camera id>";
//authentification
$response = get_web_page("http://diskstation:5000/webapi/auth.cgi?api=SYNO.API.Auth&method=Login&version=2&account=". $user."&passwd=".$password."&session=SurveillanceStation&format=sid");
//echo $response;
$resArr = array();
$resArr = ($response);
$resArr = json_decode($response,true);
//sid in the array
$sid=array();
$sid=$resArr[data];
//echo $sid[sid];
//Request API info:
//http://diskstation:5000/webapi/query.cgi?api=SYNO.API.Info&method=Query&version=1&query=SYNO.SurveillanceStation.ExternalRecording
//List camera's to find camera ID:
//http://diskstation:5000/webapi/_______________________________________________________entry.cgi?api=SYNO.SurveillanceStation.Camera&method=List&version=1&offset=1&limit=30&sid=<sid>
//look for: "id":
//send Start record
$url="http://diskstation:5000/webapi/_______________________________________________________entry.cgi?api=SYNO.SurveillanceStation.ExternalRecording&method=Record&version=2&cameraId=". $cameraid. "&_sid=".$sid[sid]."&action=";
//echo 'url: '.$url.'<br />';
$response = get_web_page($url.'start');
sleep(10);
$response = get_web_page($url.'stop');
function get_web_page($url) {
$options = array (CURLOPT_RETURNTRANSFER => true, // return web page
CURLOPT_HEADER => false, // don't return headers
CURLOPT_FOLLOWLOCATION => true, // follow redirects
CURLOPT_ENCODING => "", // handle compressed
CURLOPT_USERAGENT => "test", // who am i
CURLOPT_AUTOREFERER => true, // set referer on redirect
CURLOPT_CONNECTTIMEOUT => 120, // timeout on connect
CURLOPT_TIMEOUT => 120, // timeout on response
CURLOPT_MAXREDIRS => 10 ); // stop after 10 redirects
$ch = curl_init ( $url );
curl_setopt_array ( $ch, $options );
$content = curl_exec ( $ch );
$err = curl_errno ( $ch );
$errmsg = curl_error ( $ch );
$header = curl_getinfo ( $ch );
$httpCode = curl_getinfo ( $ch, CURLINFO_HTTP_CODE );
curl_close ( $ch );
$header ['errno'] = $err;
$header ['errmsg'] = $errmsg;
$header ['content'] = $content;
echo 'response:<br />'.$content.'<br />';
return $header ['content'];
}
?>
</pre>
preferences:
54.63 ms | 402 KiB | 5 Q