Created
September 8, 2010 21:32
-
-
Save lamont-granquist/570878 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/local/perl-5.10.1/bin/perl | |
use strict; | |
use warnings; | |
use Data::Dumper; | |
use JSON::RPC::Common::Marshal::HTTP; | |
use LWP::UserAgent; | |
my $ua = LWP::UserAgent->new; | |
my $req_data = { | |
jsonrpc => "2.0", | |
method => "user.authenticate", | |
params => { user=>'admin', password=>'zabbix' }, | |
}; | |
my $req_obj = JSON::RPC::Common::Procedure::Call->inflate($req_data); | |
my $m = JSON::RPC::Common::Marshal::HTTP->new; | |
my $req = $m->call_to_request($req_obj); | |
$req->uri('http://127.0.0.1/zabbix/api_jsonrpc.php'); | |
my $res = $ua->request($req); | |
if($res){ | |
if ($res->is_error) { | |
print "Error : ", $res->error_message; | |
} else { | |
print "FOO:\n" . $res->content . "\n"; | |
} | |
} else { | |
print $ua->status_line; | |
} | |
#my $res_obj = $m->response_to_result($res); | |
#print Dumper($res_obj); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment