| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package WWW::TextMarks; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
70679
|
use 5.008000; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
34
|
|
|
4
|
1
|
|
|
1
|
|
5
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
32
|
|
|
5
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
|
1
|
|
|
|
|
6
|
|
|
|
1
|
|
|
|
|
40
|
|
|
6
|
1
|
|
|
1
|
|
854
|
use LWP::Simple; |
|
|
1
|
|
|
|
|
340607
|
|
|
|
1
|
|
|
|
|
9
|
|
|
7
|
1
|
|
|
1
|
|
1019
|
use XML::Simple; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 NAME |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
WWW::TextMarks - Provides access to the TextMarks SMS Service V2 API |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
use WWW::TextMarks; |
|
18
|
|
|
|
|
|
|
my $tm = WWW::TextMarks->new( |
|
19
|
|
|
|
|
|
|
apik => 'example_com_12345678', |
|
20
|
|
|
|
|
|
|
user => '5556781234', |
|
21
|
|
|
|
|
|
|
pass => 'y0ur$ekretPassword', |
|
22
|
|
|
|
|
|
|
tm => 'yourtextmark', |
|
23
|
|
|
|
|
|
|
); |
|
24
|
|
|
|
|
|
|
my $res = $tm->send('5559994321', 'Hey, pick up your dry cleaning.'); |
|
25
|
|
|
|
|
|
|
if ($res->{success}) |
|
26
|
|
|
|
|
|
|
{ |
|
27
|
|
|
|
|
|
|
print "Yippie.\n"; |
|
28
|
|
|
|
|
|
|
} |
|
29
|
|
|
|
|
|
|
else |
|
30
|
|
|
|
|
|
|
{ |
|
31
|
|
|
|
|
|
|
print "Error: $res->{error}\n"; |
|
32
|
|
|
|
|
|
|
} |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
WWW::TextMarks provides access to the TextMarks SMS Service V2 API. |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
Currently, it only allows you to send text messages to individual subscribers. |
|
39
|
|
|
|
|
|
|
Eventually, it'll also allow you to maintain your subscriber list and perform |
|
40
|
|
|
|
|
|
|
the full set of tasks made available by the TextMarks API. |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
Patches are welcome in case you get to it before I do. :-) |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head1 METHODS |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head2 new |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
See SYNOPSIS above for an example. |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
Required: apik, user, pass, tm. |
|
51
|
|
|
|
|
|
|
Optional: url |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
Setting the C is not recommended unless the embedded URL in this module |
|
54
|
|
|
|
|
|
|
fails to work properly or if you require an alternate URL provided by TextMarks. |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
The C is created by registering for an API key at: |
|
57
|
|
|
|
|
|
|
L |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
The C and C is your TextMarks website login username and password. |
|
60
|
|
|
|
|
|
|
Your username is most likely your cell phone number. |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=cut |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub new |
|
65
|
|
|
|
|
|
|
{ |
|
66
|
|
|
|
|
|
|
my $self = bless({}, shift); |
|
67
|
|
|
|
|
|
|
my %opts = @_; |
|
68
|
|
|
|
|
|
|
$self->{url} = $opts{url} || 'http://dev1.api.textmarks.com/Messaging/sendText/?apik=%%apik%%&auth_user=%%user%%&auth_pass=%%pass%%&tm=%%tm%%&to=%%phone%%&msg=%%message%%'; |
|
69
|
|
|
|
|
|
|
$self->{apik} = $opts{apik}; # http://www.textmarks.com/dev/api/reg/?ref=devapi |
|
70
|
|
|
|
|
|
|
$self->{user} = $opts{user}; # textmarks username |
|
71
|
|
|
|
|
|
|
$self->{pass} = $opts{pass}; # textmarks password |
|
72
|
|
|
|
|
|
|
$self->{tm} = $opts{tm}; # textmark |
|
73
|
|
|
|
|
|
|
return $self; |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head2 send |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
See SYNOPSIS above for an example. |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
The first argument is the SMS recipient's phone number. The second argument is |
|
81
|
|
|
|
|
|
|
the message to send. There are no other arguments. |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
If you wish to send to many recipients, just call C multiple times, once |
|
84
|
|
|
|
|
|
|
per recipient. |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=cut |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub send |
|
89
|
|
|
|
|
|
|
{ |
|
90
|
|
|
|
|
|
|
my $self = shift; |
|
91
|
|
|
|
|
|
|
my $phone = shift; |
|
92
|
|
|
|
|
|
|
my $message = shift; |
|
93
|
|
|
|
|
|
|
$message =~ s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg; |
|
94
|
|
|
|
|
|
|
my $url = $self->{url}; |
|
95
|
|
|
|
|
|
|
$url =~ s/(%%([^%]+)%%)/$self->{$2}||$1/eg; |
|
96
|
|
|
|
|
|
|
$url =~ s/%%phone%%/$phone/g; |
|
97
|
|
|
|
|
|
|
$url =~ s/%%message%%/$message/g; |
|
98
|
|
|
|
|
|
|
my $response = get($url); |
|
99
|
|
|
|
|
|
|
my $resxml = { |
|
100
|
|
|
|
|
|
|
error => 'Response parser error', |
|
101
|
|
|
|
|
|
|
response => $response, |
|
102
|
|
|
|
|
|
|
}; |
|
103
|
|
|
|
|
|
|
eval |
|
104
|
|
|
|
|
|
|
{ |
|
105
|
|
|
|
|
|
|
$resxml = XMLin($response); |
|
106
|
|
|
|
|
|
|
}; |
|
107
|
|
|
|
|
|
|
$resxml->{success} = ($resxml->{TMHead}->{ResMsg} eq 'Success' || 0); |
|
108
|
|
|
|
|
|
|
$resxml->{error} = $resxml->{TMHead}->{ResMsg} unless $resxml->{success}; |
|
109
|
|
|
|
|
|
|
return $resxml; |
|
110
|
|
|
|
|
|
|
} |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
Copyright (C) 2009 by Dusty Wilson, Edusty@megagram.comE |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
|
117
|
|
|
|
|
|
|
it under the same terms as Perl itself, either Perl version 5.8.0 or, |
|
118
|
|
|
|
|
|
|
at your option, any later version of Perl 5 you may have available. |
|
119
|
|
|
|
|
|
|
=cut |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
1; |