bonjour à tous
je n'arrive pas à utilisé la commande GetSnapshot
je ramene bien un truc mais le format ne correspond pas à du jpeg
le fait de mettre le header en image/JPEG ne change rien
en PHP
//authentification
$response = get_web_page("http://192.168.X.X:5000/webapi/auth.cgi?api=SYNO.API.Auth&method=Login&version=2&account=toto&passwd=1234&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];
//
//$response = get_web_page("http://192.168.X.X:5000/webapi/SurveillanceStation/camera.cgi?api=SYNO.SurveillanceStation.Camera&method=GetInfo&version=1&cameraIds=2&additional=device&_sid=".$sid[sid]);
//echo $response;
$response = get_web_page("http://192.168.X.X:5000/webapi/SurveillanceStation/camera.cgi?api=SYNO.SurveillanceStation.Camera&method=GetSnapshot&version=1&cameraId=2&_sid=".$sid[sid]);
echo $response;
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;
return $header ['content'];
}
si quelqu'un c'est déjà pris la tête !!!!
steve