File Coverage

blib/lib/WWW/SMS/GsmboxDE.pm
Criterion Covered Total %
statement 12 34 35.2
branch 0 8 0.0
condition n/a
subroutine 4 6 66.6
pod 0 1 0.0
total 16 49 32.6


line stmt bran cond sub pod time code
1             #Copyright (c) 2001 Giulio Motta. All rights reserved.
2             #http://www-sms.sourceforge.net/
3             #This program is free software; you can redistribute it and/or
4             #modify it under the same terms as Perl itself.
5             #
6             # de.gsmbox.com modelled after GsmboxUK,
7             # looks promising, but it does not work...
8             # The original webpage also fails, hmmm.
9             # Thu Jun 27 20:19:37 CEST 2002, Juergen Weigert, jw@netvision.de
10              
11             package WWW::SMS::GsmboxDE;
12 1     1   475 use Telephone::Number;
  1         2  
  1         143  
13             require Exporter;
14             @ISA = qw(Exporter);
15             @EXPORT = qw();
16             @EXPORT_OK = qw(@PREFIXES _send MAXLENGTH);
17              
18             @PREFIXES = (Telephone::Number->new('49', [
19             qw(151 160 170 171 175 152 1520 162 172 173 174 163 177 178 176 179)
20             ], undef)
21             );
22              
23             $VERSION = '1.00';
24              
25             sub MAXLENGTH () {120} # maximum message length
26              
27             sub hnd_error {
28 0     0 0   $_ = shift;
29 0           $WWW::SMS::Error = "Failed at step $_ of module GsmboxDE.pm";
30 0           return 0;
31             }
32              
33             sub _send {
34 0     0     my $self = shift;
35              
36 1     1   4 use HTTP::Request::Common qw(GET POST);
  1         7  
  1         53  
37 1     1   4 use HTTP::Cookies;
  1         2  
  1         63  
38 1     1   4 use LWP::UserAgent;
  1         2  
  1         514  
39              
40 0           return hnd_error("0 (GsmboxDE is unfinished)");
41            
42 0 0         $self->{smstext} = substr($self->{smstext}, 0, MAXLENGTH - 1) if (length($self->{smstext})>MAXLENGTH);
43              
44 0           my $ua = LWP::UserAgent->new;
45 0           $ua->agent('Mozilla/5.0');
46 0 0         $ua->proxy('http', $self->{proxy}) if ($self->{proxy});
47 0           $ua->cookie_jar(HTTP::Cookies->new(
48             file => $self->{cookie_jar},
49             autosave => 1
50             )
51             );
52              
53             #STEP 1
54 0           my $step = 1;
55 0           my $req = POST 'http://de.gsmbox.com/freesms/preview.gsmbox',
56             [
57             messaggio => $self->{smstext},
58             prefisso => $self->{prefix},
59             telefono => $self->{telnum},
60             pluto => '8790',
61             country => 'de',
62             SUBMIT => 'Absenden'
63             ];
64              
65 0           my $file = $ua->request($req)->as_string;
66 0 0         return &hnd_error($step) unless $file =~ //i;
67 0           my $image_button = $1;
68 0           my $width_button = $2;
69 0           my $height_button = $3;
70             #STEP 1
71              
72             #STEP 2
73 0           $step++;
74 0           $req = POST 'http://uk.gsmbox.com/freesms/conf_invio.gsmbox',
75             [
76             messaggio => $self->{smstext},
77             telefono => $self->{telnum},
78             prefisso => $self->{prefix},
79             country => 'de',
80             '96fe31369659d886e1723c9a46a08bb6' => 'f667dbb8ed2bbf65cd13476e9a21ea8a',
81             $image_button.'.x' => int(rand($width_button)),
82             $image_button.'.y' => int(rand($height_button)),
83             ];
84              
85 0           $file = $ua->simple_request($req)->as_string;
86 0 0         return &hnd_error($step) unless $file =~ /successfully/i;
87             #STEP 2
88              
89 0           1;
90             }
91              
92             1;