File Coverage

blib/lib/WWW/SMS/GoldenTelecom.pm
Criterion Covered Total %
statement 9 25 36.0
branch 0 6 0.0
condition n/a
subroutine 3 5 60.0
pod 0 1 0.0
total 12 37 32.4


line stmt bran cond sub pod time code
1             #!/usr/bin/perl -w
2            
3             #Automagically generated from SMSSplitter scripts
4             #Credits goes to Aleph0 Edition! http://www.aleph0.f2s.com for the original
5             #implementation as a SMSsplitter script
6             #Simply reimplemented by Giulio Motta
7            
8             package WWW::SMS::GoldenTelecom;
9            
10             require Exporter;
11             @ISA = qw(Exporter);
12             @EXPORT = qw();
13             @EXPORT_OK = qw(@PREFIXES _send MAXLENGTH);
14             undef @PREFIXES;
15             $VERSION = '1.00';
16            
17             sub MAXLENGTH () {160}
18            
19             sub hnd_error {
20 0     0 0   $_ = shift;
21 0           $WWW::SMS::Error = "Failed at step $_ of module GoldenTelecom.pm\n";
22 0           return 0;
23             }
24            
25             sub _send {
26 0     0     my $self = shift;
27            
28 1     1   744 use HTTP::Request::Common qw(GET POST);
  1         3  
  1         62  
29 1     1   6 use HTTP::Cookies;
  1         2  
  1         19  
30 1     1   5 use LWP::UserAgent;
  1         3  
  1         305  
31            
32 0           $ua = LWP::UserAgent->new;
33 0           $ua->agent('Mozilla/5.0');
34 0 0         $ua->proxy('http', $self->{proxy}) if ($self->{proxy});
35 0           $ua->cookie_jar(HTTP::Cookies->new(
36             file => $self->{cookie_jar},
37             autosave => 1
38             )
39             );
40            
41 0 0         $self->{smstext} = substr($self->{smstext}, 0, MAXLENGTH - 1) if (length($self->{smstext})>MAXLENGTH);
42            
43             #STEP 1
44 0           my $step = 1;
45 0           $req = POST 'http://sms.gt.com.ua:8080/SendSM.htm',
46             [
47             'SM' => $self->{smstext} ,
48             'num' => (MAXLENGTH - length($self->{smstext})) ,
49             'MN' => '+' . $self->{intpref} . $self->{prefix} . $self->{telnum} ,
50             'CS' => 'S' ,
51             ];
52 0           $req->headers->referer('http://sms.gt.com.ua/index.htm');
53 0           $file = $ua->simple_request($req)->as_string;
54 0 0         return &hnd_error($step) unless ($file =~ /Message sent/s);
55             #STEP 1
56 0           $ua->cookie_jar->clear('sms.gt.com.ua');
57 0           1;
58             }
59            
60             1;