-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathclient.pl
More file actions
66 lines (42 loc) · 1.23 KB
/
Copy pathclient.pl
File metadata and controls
66 lines (42 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/perl
use strict;
use JSON;
use LWP::UserAgent;
use Data::Dumper;
#---------------------------------------------------------
my @properties=();
my %property = (
"UniqueID" => "4500199",
"AgentID" => "12345",
"Date" => "2014-09-05",
"Hits" => "114",
);
push(@properties,{%property});
%property = (
"UniqueID" => "4500200",
"AgentID" => "12345",
"Date" => "2014-09-05",
"Hits" => "205",
);
push(@properties,{%property});
my %data = (
"Apikey" => "54321abcde",
"Test" => "0",
"Properties" => \@properties,
);
my $json = encode_json(\%data);
my $ua = LWP::UserAgent->new;
my $url = "https://api.mydesktop.com.au/cgi-bin/test/propertyhits.cgi";
my $headers = HTTP::Headers->new(Content_Type => "application/json");
my $request = HTTP::Request->new('POST',$url,$headers,$json);
my $response = $ua->request($request);
if ($response->is_success) {
my $content = $response->decoded_content();
$content = decode_json($content);
my $success = $content->{"success"};
my $message = $content->{"msg"};
# Do something with the response
} else {
# Handle failure
}
exit;