DAHUA snapshop "Error Invalid Authority" php

zaklahunik

n3wb
Joined
Jul 30, 2022
Messages
1
Reaction score
0
Location
GDL
So i have 2 dahua cameras, different model same condditions. Both in the same subnet. I have a php file where I call cURL on both to get a snapshot and save it.
The thing is when i mount the server in my Apple MAcbookPro everything works. But when I try to do this from a Windows 10 computer the second camera shows the error "Error Invalid Authoriry"

Heere is the code:

function get_image($img_name)
{
date_default_timezone_set('America/Mexico_City');
/to get the image from camera and save it to a local file
$login = 'admin';
$password = '*';
$url = ' $url_back = '

/This is the one that works on mac and windows
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($ch, CURLOPT_USERPWD, "$login:$password");
$result = curl_exec($ch);
curl_close($ch);
if(curl_errno($ch)){
throw new Exception(curl_error($ch), 500);
}

/This is the one that NOT work on windows enviroment
$ch2 = curl_init();
curl_setopt($ch2, CURLOPT_URL,$url_back);
curl_setopt($ch2, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch2, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST); /i use ANY also with no luck
curl_setopt($ch2, CURLOPT_USERPWD, "$login:$password");
$result2 = curl_exec($ch2);
curl_close($ch2);
if(curl_errno($ch2)){
throw new Exception(curl_error($ch2), 500);
}
$im = imagecreatefromstring($result);
$im_back = imagecreatefromstring( $result2);
/ header('Content-Type: image/jpeg');
/use this next 2 lines to change size if required
/ $newnew = imagecreatetruecolor(3840,2160);
/ imagecopyresized($newnew, $im, 0, 0, 0, 0,1920,1080, 1920, 1080);
/ $newnewfile = "$now.jpg";
$valid = imagejpeg($im, "images/$img_name");
$img_name_back = "back_" . $img_name;
imagejpeg($im_back, "images/$img_name_back");
if(!$valid){
echo "Problemas para guardar la imagen";
die;
}
imagedestroy($im);
imagedestroy($im_back);

/Return to succes page and display images.
header("Location: success_registry.php");
die;
}
 
Top