line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package SMS::Send::TW::Qma; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
26918
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
39
|
|
4
|
1
|
|
|
1
|
|
6
|
use base 'SMS::Send::Driver'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
965
|
|
5
|
1
|
|
|
1
|
|
2446
|
use WWW::Mechanize; |
|
1
|
|
|
|
|
169565
|
|
|
1
|
|
|
|
|
44
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
13
|
use vars qw{$VERSION}; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
68
|
|
8
|
|
|
|
|
|
|
BEGIN { |
9
|
1
|
|
|
1
|
|
429
|
$VERSION = '0.01'; |
10
|
|
|
|
|
|
|
} |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new { |
13
|
0
|
|
|
0
|
1
|
|
my ($class, %params) = @_; |
14
|
|
|
|
|
|
|
|
15
|
0
|
|
|
|
|
|
foreach(qw/username password/) { |
16
|
0
|
0
|
|
|
|
|
Carp::croak("No $_ specified") unless(defined $params{"_$_"}); |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
0
|
|
|
|
|
|
my $self = bless { %params }, $class; |
20
|
|
|
|
|
|
|
|
21
|
0
|
|
|
|
|
|
return $self; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub send_sms { |
25
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
26
|
0
|
|
|
|
|
|
my %params = @_; |
27
|
|
|
|
|
|
|
|
28
|
0
|
|
|
|
|
|
my $baseurl = 'http://www.qma.com/cdp/jsp/websms'; |
29
|
0
|
|
|
|
|
|
my $posturl = 'http://www.qma.com/cdp/jsp/websms/SMS_Action.jsp'; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# Get the message and destination |
32
|
0
|
|
|
|
|
|
my $message = $self->_MESSAGE( $params{text} ); |
33
|
0
|
|
|
|
|
|
my $recipient = $self->_TO( delete $params{to} ); |
34
|
|
|
|
|
|
|
|
35
|
0
|
|
|
|
|
|
my $ua = WWW::Mechanize->new( |
36
|
|
|
|
|
|
|
agent => __PACKAGE__." v. $VERSION", |
37
|
|
|
|
|
|
|
); |
38
|
|
|
|
|
|
|
|
39
|
0
|
|
|
|
|
|
$ua->agent_alias('Windows IE 6'); |
40
|
0
|
|
|
|
|
|
$ua->get("$baseurl/SMS_send.jsp"); |
41
|
0
|
|
|
|
|
|
$ua->submit_form( |
42
|
|
|
|
|
|
|
form_name => 'form1', |
43
|
|
|
|
|
|
|
fields => { |
44
|
|
|
|
|
|
|
'j_username' => $self->{"_username"}, |
45
|
|
|
|
|
|
|
'j_password' => $self->{"_password"}, |
46
|
|
|
|
|
|
|
}, |
47
|
|
|
|
|
|
|
); |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
# Should be ok now, right? Let's send it! |
50
|
|
|
|
|
|
|
# Input SMS_Message, Recipients |
51
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
$ua->post($posturl, |
53
|
|
|
|
|
|
|
[ |
54
|
|
|
|
|
|
|
'receivers' => $recipient, |
55
|
|
|
|
|
|
|
'sendContent' => $message, |
56
|
|
|
|
|
|
|
'iscurrentsend' => 'Y', |
57
|
|
|
|
|
|
|
'func' => 'addSmsMessageInfo', |
58
|
|
|
|
|
|
|
'targetURL' => 'SMS_send_result.jsp', |
59
|
|
|
|
|
|
|
# 'sender' => "0953858839", |
60
|
|
|
|
|
|
|
# 'contractid' => 'sf093', |
61
|
|
|
|
|
|
|
]); |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
|
64
|
0
|
|
|
|
|
|
$ua->content() =~ /document.location="(.+)"/i; |
65
|
0
|
|
|
|
|
|
$ua->get("$baseurl/$1&iscurrentsend=Y"); |
66
|
|
|
|
|
|
|
|
67
|
0
|
|
|
|
|
|
return $ua->content(); |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub _MESSAGE { |
72
|
|
|
|
|
|
|
|
73
|
0
|
0
|
|
0
|
|
|
my $class = ref $_[0] ? ref shift : shift; |
74
|
0
|
|
|
|
|
|
my $message = shift; |
75
|
0
|
0
|
|
|
|
|
unless ( length($message) <= 160 ) { |
76
|
0
|
|
|
|
|
|
Carp::croak("Message length limit is 160 characters"); |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
0
|
|
|
|
|
|
return $message; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub _TO { |
83
|
0
|
0
|
|
0
|
|
|
my $class = ref $_[0] ? ref shift : shift; |
84
|
0
|
|
|
|
|
|
my $to = shift; |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
# International numbers need their + removed |
87
|
0
|
|
|
|
|
|
$to =~ y/0123456789//cd; |
88
|
|
|
|
|
|
|
|
89
|
0
|
|
|
|
|
|
return $to; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
1; |
94
|
|
|
|
|
|
|
__END__ |