| 1 | #!/usr/local/bin/perl | ||
| 2 | use strict; | ||
| 3 | use warnings; | ||
| 4 | use Getopt::Std qw{getopts}; | ||
| 5 | use DateTime; | ||
| 6 | use SMS::Send::VoIP::MS; | ||
| 7 | |||
| 8 | my $opt = {}; | ||
| 9 | getopts('u:p:f:d', $opt); #debug | ||
| 10 | my $syntax = qq{$0 [-u username] [-p password] [-f from_phone] [-d] to_phone "text"\n}; | ||
| 11 | my $username = $opt->{'u'}; #default undef from INI file | ||
| 12 | my $password = $opt->{'p'}; #default undef from INI file | ||
| 13 | my $from = $opt->{'f'}; #default undef from INI file | ||
| 14 | my $debug = $opt->{'d'} ? 1 : 0; | ||
| 15 | my $to = shift or die($syntax); | ||
| 16 | my $text = shift or die($syntax); | ||
| 17 | my $service = SMS::Send::VoIP::MS->new(username=>$username, password=>$password, did=>$from); | ||
| 18 | my $status = $service->send_sms( | ||
| 19 | to => $to, | ||
| 20 | text => $text, | ||
| 21 | ); | ||
| 22 | if ($debug) { | ||
| 23 | require Data::Dumper; | ||
| 24 | print Data::Dumper::Dumper($service->{'__data'}); | ||
| 25 | print '+' x 80, "\n", $service->{'__content'}, "\n", '-' x 80, "\n"; | ||
| 26 | } | ||
| 27 | |||
| 28 | printf "%s: Phone: %s, Text: %s, Status: %s\n", DateTime->now, $to, $text, $status; | ||
| 29 | |||
| 30 | exit 1 unless $status; | ||
| 31 | |||
| 32 | __END__ |