Re: Using API to setup cams
Posted: Wed Nov 25, 2015 1:20 pm
Starting to work on some perl code to see what I might be able to come up with for useless yet geeky things for zoneminder. Having never used some of these modules I'm kind of stuck at the initial login to ZM.
I expected to get back the html from the main page but only got:
My goal here is to use perl to grab monitor and zone configs via API, save the json output and then use that as a sort of backup. And eventually be able to wipe those configs and rebuild if it becomes necessary or if I just want to reorganize. Wish I had a much cooler goal here, but I'm just playing with this stuff to get my head filled with more perl goodness.
Code: Select all
#!/usr/bin/perl
use HTTP::Cookies;
use LWP;
use LWP::UserAgent;
$url = 'https://localhost/zm/index.php';
$user = 'username';
$pass = 'password';
$cookie_jar = HTTP::Cookies->new(
file => "$ENV{'HOME'}/lwp_cookies.dat",
autosave => 1,
);
my $browser = LWP::UserAgent->new;
$browser->cookie_jar($cookie_jar);
my $ua = LWP::UserAgent->new;
$ua->timeout(10);
$ua->env_proxy;
$ua->agent("USER/AGENT/IDENTIFICATION");
$request = HTTP::Request->new(GET => $url);
$request->authorization_basic($user, $pass);
$response = $ua->request($request);
$content = $response->content();
print $content;
Code: Select all
Can't connect to localhost:443