GDS3710: capture picture with HTTP API

physical-security

#1

Hi,

Is there a command to initiate a photo capture with the HTTP API?

In the documentation there is an example to request a snapshot, but it is not clear (to me anyway) whether it is requesting an already captured photo or if it will make the GDS3710 take a picture and send it. It also did not provide the command string to send for this example either, only that you have to authorize with “type=1” for the MJPEG Stream mode, unless I overlooked it.

Here is the documentation that I am looking at:

Thank you in advance.


Change in API
Chrome Extension to release the lock
GDS3710: capture picture with HTTP API - not working
#2

Did you find anything? I’m looking for that too, and yes, the API documentation doesn’t help.


#3

Assuming the GDS using latest firmware: (1.0.2.22 as latest BETA as of today)

the SNAPSHOT command for GDS3710 is:

            https://IP_GDS/jpeg/view.html

the MJPEG command for GDS3710 is:

            https://IP_GDS/jpeg/mjpeg.html 

There will be a popup asking entering credentials, after correct password, you should be able to do that as long as the session is alive. If you want to write a script, sample at Page 109 of the HTTP API should help to guide how to program. Hope this helps. Thanks for using GDS3710 product.


#4

Is there a new version of the HTTP API published anywhere? Because the one I got has 79 pages (http://www.grandstream.com/sites/default/files/Resources/gds37xx_http_api.pdf). Yes, I need to script it.


#5

Ok, I guess I found it. So, if my appreciation is correct, is not an API implementation per se, but a reverse engineer on how the authentication page works in a browser (using challenge codes and cookies). Right?


#6

Are these URL command for use with the API?

I tried these commands and got a Page Not Found error.

Also would you mind linking the other HTTP API document, I still have only seen the 79 page document that me and @gerardocb have linked.

Thank you.


#7

Also when we do initiate this snapshot, where will this image go?

Will it go to a FTP server that I have configured?

Can I configure it to send the image through the RS485 pins that are on the GDS3710 if I have a device connected to it to retrieve the image?

How does the Live View snapshot send to the same computer that is running the Web GUI?

Maybe if I can configure a path in my device, can I then make the GDS3710 send to that path similar to how the Live View does it?

Also when I use https://…, I get a SSL verification error. Where can I get certificates for this product.

I did switch the access parameter to HTTP instead of HTTPS and tried the URLs again.

This time I got the html format for the page.

Still unsure about how to get the images though.

Thank you again for the help.


#8

@MrNeondal:

For the snapshots handled by GDS, it will either sending out by FTP or email (if configured), or internal flash (if enabled).

  1. Strongly suggest to use FTP to upload those snapshots to store in server (like GXV3275 with built-in FTP server and with inserted SD card)
  2. internal flash is very limited, the application server like GDSManager will pull the snapshots to avoid the storage full happens.

For the snapshot clicked by the browser WebGUI (plugin), it will be stored in the computer hard disk running the browser. User can configure the storage path to save to other folder or places.

For the HTTP/HTTPS API, you need write scripts to handle the credentials, then pull the snapshot based on the command sending to GDS.

Maybe @gerardocb can comment more on how to do this. Thanks!


#9

Sounds good.

I do hope @gerardocb could put some insight to those scripts for the snapshot.

Maybe a way I can specify a path for the image through the API?

Thank you once again for your help.


#10

I was really hoping to find a nicer way to work along with this, but it seems that’s the only way. Resuming, there’s no way to make a single call to take the image capture from the GDS3710, as it’s for most of the other manufacturer’s.

Now, as for what to do (according to the “API” documentation):

  1. You have to call the URL with the URI /goform/login
  2. You have to read the response from the GDS3710, which should include a challenge code.
  3. You have to create a md5 hash with the challenge code, an specific string for the GDS3710 and the actual admin password (there’s only one password, the admin’s).
  4. You have to send this hash to the 3710 for it to validate if it’s a valid password.
  5. If it is, the 3710 will return an “accepted” code along with a session cookie which you have to read and user further.
  6. Once you have the session cookie, you have to use it in order to do the actual request for the capture.

IMHO, that’s a real P.I.T.A to do that. As a matter of fact, that’s exactly what the browser does on the live capture web page @w00t sent yesterday. No way this can be considered an API implementation.

Why doesn’t Grandstream use the very simple HTTP basic auth for this (which simplifies the process for developers)? Beats me.


#11

Hi,

for all those who want to use it right now:

http://www.loxwiki.eu/pages/viewpage.action?pageId=8388623

++
Andy


#12

HI @gerardocb,

Thanks for the info.

I did manage to create a script that handled the authentication login for me.

Now all I need it the snapshot request URL as the previous URLs that @w00t had posted only responded with the HTML format of the page.

Not sure if my request is missing something to specify that I want the image or something.

Also GS support had gotten back to my ticket and had queried me for my question about the exact command.
They also said that the image in response to the command would go to the HTTP server making the request.

Now all I need is the command, or correct use of the command, and then a way to specify a path for it.

I do also think this is a pain to deal with as @gerardocb said.

But anyway, thank you for the information and help and I look forward to hopefully getting this working with you all.


#13

Hi all,

So I finally got the Snapshot to work.

So I did the authentication procedure and then I sent the following URL:

https://GDS_IP/snapshot/view0.jpg

I did have to put “>> directory/pic.jpg” at the end of my request to save the picture in my directory.

Since this worked, I believe that we could also get the image from the other streams as specified in other product documentations by using view0, view4, and view8.

The auth process and this command is all sent via CURL in a shell script.

Make sure to use the cookies that you get form the auth process.

Thank you all so much for the help.


#14

[quote=“MrNeondal, post:13, topic:20299”]Hi all,

So I finally got the Snapshot to work.

So I did the authentication procedure and then I sent the following URL:

https://GDS_IP/snapshot/view0.jpg

I did have to put “>> directory/pic.jpg” at the end of my request to save the picture in my directory.

Since this worked, I believe that we could also get the image from the other streams as specified in other product documentations by using view0, view4, and view8.

The auth process and this command is all sent via CURL in a shell script.

Make sure to use the cookies that you get form the auth process.

Thank you all so much for the help.[/quote]

Hi MrNeondal,

good job :slight_smile:
Can you send me the curl script for authentication?

++
Andy


#15

I too finally managed to get the capture. I still don’t get why they don’t implement it through HTTP Basic authentication, which handles most of the challenge/password part.

Now I’m facing another issue. I can’t find any call on the API to just open the door. That’s one of the reasons we’re in the need to work with the API. Does anybody knows if this is possible?


#16

[quote=“ak0815, post:14, topic:20299”][quote=“MrNeondal, post:13, topic:20299”]Hi all,

So I finally got the Snapshot to work.

So I did the authentication procedure and then I sent the following URL:

https://GDS_IP/snapshot/view0.jpg

I did have to put “>> directory/pic.jpg” at the end of my request to save the picture in my directory.

Since this worked, I believe that we could also get the image from the other streams as specified in other product documentations by using view0, view4, and view8.

The auth process and this command is all sent via CURL in a shell script.

Make sure to use the cookies that you get form the auth process.

Thank you all so much for the help.[/quote]

Hi MrNeondal,

good job :slight_smile:
Can you send me the curl script for authentication?

++
Andy[/quote]

Hi ak0815,
Sure thing, and I did do this on Ubuntu 16.04 in case you wanted that information too.


#!/bin/bash

##Authentication Login
return="$(curl -k -H ‘Content-Type: text/xml’ -D ‘cookies.txt’ ‘https://GDS_IP/goform/login?cmd=login&user=GDS_USERNAME&type=1’)"

##Get ChallengeCode
substring1=${return##}
final=${substring1%%
}

##Calculate md5 checksum
mdstr="$(echo -n $final:GDS3710lZpRsFzCbM:GDS_PASSWORD | md5sum | tr -d ‘/n’)"

M="$(echo $mdstr | cut -d’ ’ -f1 | tr -d ‘/n’)"

curl -k -H “Content-Type: text/xml” -D “cookies.txt” “https://GDS_IP/goform/login?cmd=login&user=GDS_USERNAME&authcode=$M&type=1”

##Request to take snapshot
curl -k -H “Content-Type: image/jpeg” --cookie “cookies.txt” “https://GDS_IP/snapshot/view0.jpg” >> gds_snap.jpg


Insert your GDS3710 IP, USERNAME, and PASSWORD

This has worked for me every time so if something goes wrong then I would suggest that you try each command separately.
Make sure you also have the curl and md5sum packages installed on your linux machine.

If you have anymore questions I will try to monitor this and answer.

Thank you all again for your help with this.


#17

Thank you for sharing this. :slight_smile:


#18

Thanks :slight_smile:


#19

Hi all,
thanks for your script MrNeondal.
Without your hplp I wouldn’t be so far in solution. I’am not experienced in linux shell programming, but the script works until this line:

"curl -k -H “Content-Type: text/xml” -D “cookies.txt” “https://GDS_IP/goform/login?cmd=login&user=GDS_USERNAME&authcode=$M&type=1"”

The fault I get, is because of the password, it is not correct.
I tried the script step by step and I think it is because of the md5 hash. If I take the md5 hash direct in the terminal and not from the script, I get another solution, which works in the line above. Could it be, that my system calculates it wrong because of another shell terminal or something like that?
I use linux mint 17.3 Cinnamon.
Thanks for your help in advance,

gum2002


#20

You did adjust GDS_USERNAME?