GDS3710: capture picture with HTTP API

physical-security

#21

Hi gum2002,

Like @AllUp said, did you change the GDS_USERNAME and IP,etc. with your own GDS3170 parameters?

Also I am not 100% sure about Cinnamon, since I have been using Ubuntu since I can remember, but it could be possible that the md5 could be outputting something different.

Remember a simple space or any other character will change the md5.

I believe you shouldn’t have a problem since most linux systems should be able to run the same or similar commands with the same outputs(I am not a linux expert though, so don’t take my word for it).

Also do some googling.

I am no pro at shell programming either and most of these commands I merely googled to find a working answer.

Let me know the results and if you are still having problems.

Sorry I couldn’t be of more help.

Mr. Neondal


#22

I got it. The fault was the control character CR! Because of 1 character more, the md5 hash was totally different.
Thanks to all!


#23

Same code in PHP with direct return of the image to the browser (can also be saved to a file) :

<?php
function getHtml($url, $post = null) {
    $ch = curl_init();
    //curl_setopt($ch, CURLOPT_VERBOSE, true);
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($ch, CURLOPT_COOKIEJAR, '/tmp/cookie.txt');
   	curl_setopt($ch, CURLOPT_COOKIEFILE, '/tmp/cookie.txt');
    $result = curl_exec($ch);
    curl_close($ch);
    return $result;
}

$doorphone_ip = "GDS3710 IP";
$doorphone_username = "USERNAME";
$doorphone_password = "PASSWORD";

$token_url = "https://".$doorphone_ip."/goform/login?cmd=login&user=".$doorphone_username."&type=1";
$snapshot_url = "https://".$doorphone_ip."/snapshot/view0.jpg";

$result = getHtml($token_url);
try {
  $xml_result = new SimpleXMLElement($result);
} catch (Exception $e) {
  echo "bad xml";
}
$challenge_code = $xml_result->ChallengeCode;
$authcode = $challenge_code.":GDS3710lZpRsFzCbM:".$doorphone_password;
$authcode_md5 = md5($authcode);

$auth_url = "https://".$doorphone_ip."/goform/login?cmd=login&user=".$doorphone_username."&authcode=".$authcode_md5."&type=1";
$result = getHtml($auth_url);
$out = getHtml($snapshot_url);

$img = imagecreatefromstring($out);
header('Content-type: image/jpeg');
imagejpeg($img);

exit();
?>

#24

hi!

How can I change the php script that makes the MJPEG stream work?

$snapshot_url = “https://”.$doorphone_ip."/jpeg/mjpeg.html";


#25

This may help you…

  1. get ChallangeCode
    https://10.1.1.48/goform/login

    REQUEST (POST)
    cmd=login
    user=admin
    type=1

    RESPONSE

    <?xml version="1.0" encoding="UTF-8" ?> 0 b62006e5bd1b6fe3737bec5456ad41d0 OK
  2. Calculate MD% with Challenge Code returned above
    MD5( ChallengeCode:GDS3710lZpRsFzCbM:password )
    Example MD5( b62006e5bd1b6fe3737bec5456ad41d0:GDS3710lZpRsFzCbM:LSPBQutX )

    REQUEST
    Header of If-Modified-Since=0
    https://10.1.1.48/goform/login?cmd=login&user=admin&authcode=f40324f4a7de86e972edf40bfd17ef06&type=1       
    
    RESPONSE
    <?xml version="1.0" encoding="UTF-8" ?>
    <Configuration>
       <ResCode>0</ResCode>
       <RetMsg>OK</RetMsg>
    </Configuration>
    
    COOKIES
    mjpeg_sess=f40324f4a7de86e972edf40bfd17ef06
    mjpeg_uname=admin
    mjpeg_level=1
    

CHANGE THE EXPIRY OF THE COOKIES TO LONG TERM
Call h t t p s : / / ip_addr / jpeg /mjpeg.html
or for single images…
h t t p s : / / ip_addr/snapshot/view0.jpg? + Math.random();
example…
h t t p s : / / ip_addr /snapshot/view0.jpg?0.0016342343612942845