Skip to content

Instantly share code, notes, and snippets.

@hostmaster
Created July 8, 2014 07:57
Show Gist options
  • Save hostmaster/08143ed640a87dcd5b01 to your computer and use it in GitHub Desktop.
Save hostmaster/08143ed640a87dcd5b01 to your computer and use it in GitHub Desktop.
#!/usr/bin/perl
use strict;
use warnings;
# smsonline
use LWP;
use HTTP::Request;
use URI::Escape;
# devinosms
my $To = shift;
my $Txt = shift;
# SMS providers
my %send_sms_via = (
main => \&prostorsms_send
);
### MAIN
$send_sms_via{main}->($To, $Txt);
### END
sub prostorsms_send {
my $smsTo = shift;
my $smsTxt = shift;
my $smsUser = "XXXXXXXX";
my $smsPass = "YYYYYYYY";
# $smsTxt =~ s/\n/<br>/g; # nl2br
my $URL = sprintf("http://%s:%s\@gate.prostor-sms.ru/send/?phone=%s&text=%s", $smsUser, $smsPass, uri_escape($smsTo), uri_escape($smsTxt));
my $request = HTTP::Request->new(GET => $URL);
my $ua = LWP::UserAgent->new(timeout=>60);
my $response = $ua->request($request);
if( !$response->is_success ) {
print("ERR FALIED Request ".$response->status_line."\n");
return undef;
} else {
return;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment