Hi all- I am trying to enable/disable a ZM cam via HTTP. Is that possible?
Use case: I have a camera (Foscam 8905W) directed toward my spa. This is primarily for demos and watching kids play. From time to time, me and the Mrs. would like to have an adult soak. Ideally, I send an http post to disable that camera, and then re-enable the camera after the soak.
If http post is not supported, a suitable PHP script will do. Thank you in advance for any help you can provide.
Best, -Benson
HTTP post commands for ZM
Re: HTTP post commands for ZM
I'm doing something like that with curl.
I switch the the cam from Function "Modect" to Function "None" via curl.
Here is my script "controlcam.sh" :
Simply, I call ./controlcam.sh on|off
Any suggestion is appreciated
Oscar
I switch the the cam from Function "Modect" to Function "None" via curl.
Here is my script "controlcam.sh" :
Code: Select all
#!/bin/bash
JOB="$0"
COMMAND="$1"
shift
case $COMMAND in
on)
curl -s -c /tmp/curl_coockie_zm.txt "http ://127.0.0.1/zm/index.php" -d "action=login&view=postlogin&username=admin&password=mypasswd"
# ON
curl -s -b /tmp/curl_coockie_zm.txt "http ://127.0.0.1/zm/index.php" -d "view=none&action=function&mid=1&newFunction=Modect&newEnabled=1"
curl -s -b /tmp/curl_coockie_zm.txt "http ://127.0.0.1/zm/index.php" -d "view=none&action=function&mid=2&newFunction=Modect&newEnabled=1"
;;
off)
curl -s -c /tmp/curl_coockie_zm.txt "http ://127.0.0.1/zm/index.php" -d "action=login&view=postlogin&username=admin&password=mypasswd"
# OFF
curl -s -b /tmp/curl_coockie_zm.txt "http ://127.0.0.1/zm/index.php" -d "view=none&action=function&mid=2&newFunction=None&newEnabled=1" &
curl -s -b /tmp/curl_coockie_zm.txt "http ://127.0.0.1/zm/index.php" -d "view=none&action=function&mid=1&newFunction=None&newEnabled=1" &
;;
*)
echo
echo "Usage: $JOB (on|off)" 1>&2
echo
exit 1
esac
exit 0
Any suggestion is appreciated
Oscar
Re: HTTP post commands for ZM
Oscar- Thank you very much for your response. From your curl script, I was able to build an HTTP string that does the trick. Here's my method:
To disable camera ID 7 (change function to None):
[URL]/zm/index.php?view=none&action=function&mid=7&newFunction=None&newEnabled=1
To enable camera ID 7 (change function to Monitor):
[URL]/zm/index.php?view=none&action=function&mid=7&newFunction=Monitor&newEnabled=1
Oddly, no security credentials are needed. Perhaps a misconfiguration on my part?
Anyhow, just what I needed. Again, thank you! -Benson
EDIT: I was still logged in from a previous session. For that reason, I wasn't prompted for credentials, and the HTTP Get worked fine.
To disable camera ID 7 (change function to None):
[URL]/zm/index.php?view=none&action=function&mid=7&newFunction=None&newEnabled=1
To enable camera ID 7 (change function to Monitor):
[URL]/zm/index.php?view=none&action=function&mid=7&newFunction=Monitor&newEnabled=1
Oddly, no security credentials are needed. Perhaps a misconfiguration on my part?
Anyhow, just what I needed. Again, thank you! -Benson
EDIT: I was still logged in from a previous session. For that reason, I wasn't prompted for credentials, and the HTTP Get worked fine.