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