HTTP post commands for ZM

Forum for questions and support relating to the 1.24.x releases only.
Locked
bhougland
Posts: 2
Joined: Mon Feb 11, 2013 3:53 am

HTTP post commands for ZM

Post by bhougland »

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
oscar69
Posts: 2
Joined: Wed Feb 06, 2013 1:29 pm

Re: HTTP post commands for ZM

Post by oscar69 »

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" :

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

Simply, I call ./controlcam.sh on|off

Any suggestion is appreciated :)

Oscar
bhougland
Posts: 2
Joined: Mon Feb 11, 2013 3:53 am

Re: HTTP post commands for ZM

Post by bhougland »

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.
Locked