|
indvdum@0
|
1 |
#!/usr/bin/perl -w
|
|
indvdum@1
|
2 |
|
|
indvdum@1
|
3 |
# SUO PELMEN auto-record script
|
|
indvdum@1
|
4 |
# Copyright 2012, David Veliev (gotoindvdum@gmail.com).
|
|
indvdum@1
|
5 |
# This program may be used under Apache License 2.0.
|
|
indvdum@0
|
6 |
|
|
indvdum@0
|
7 |
use strict;
|
|
indvdum@0
|
8 |
use LWP::UserAgent;
|
|
indvdum@3
|
9 |
use Time::localtime;
|
|
indvdum@0
|
10 |
|
|
indvdum@0
|
11 |
$ENV{'PERL_LWP_SSL_VERIFY_HOSTNAME'} = 0;
|
|
indvdum@0
|
12 |
|
|
indvdum@3
|
13 |
my $tm = localtime;
|
|
indvdum@3
|
14 |
my $date = sprintf("%04d-%02d-%02d %02d:%02d:%02d", $tm->year + 1900, $tm->mon + 1, $tm->mday, $tm->hour, $tm->min, $tm->sec);
|
|
indvdum@0
|
15 |
|
|
indvdum@0
|
16 |
# Create a user agent object
|
|
indvdum@0
|
17 |
my $ua = LWP::UserAgent->new;
|
|
indvdum@0
|
18 |
#$ua->agent("MyApp/0.1 ");
|
|
indvdum@0
|
19 |
|
|
indvdum@0
|
20 |
# Create a request
|
|
indvdum@2
|
21 |
my $req = HTTP::Request->new(POST => 'https://office.alphatech.ru/suo-pelmen/subscribe');
|
|
indvdum@0
|
22 |
$req->content_type('application/x-www-form-urlencoded');
|
|
indvdum@0
|
23 |
$req->content('users=52');
|
|
indvdum@0
|
24 |
|
|
indvdum@0
|
25 |
# Pass request to the user agent and get a response back
|
|
indvdum@0
|
26 |
my $res = $ua->request($req);
|
|
indvdum@0
|
27 |
|
|
indvdum@0
|
28 |
# Check the outcome of the response
|
|
indvdum@0
|
29 |
if ($res->is_success) {
|
|
indvdum@0
|
30 |
print $date, " SUCCESS:\n", $res->content, "\n\n";
|
|
indvdum@0
|
31 |
}
|
|
indvdum@0
|
32 |
else {
|
|
indvdum@0
|
33 |
print $date, " FAIL:\n", $res->status_line, "\n\n";
|
|
indvdum@0
|
34 |
}
|