Created
September 28, 2019 12:09
-
-
Save D4R4/ad2f3df7c6769fe810b4b0c3392601f5 to your computer and use it in GitHub Desktop.
CGI Perl script to use POST and RESTful client and connect to SMS IR
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl -X | |
use lib '.'; | |
use strict; | |
use CGI::Carp qw(fatalsToBrowser); | |
use REST::Client; | |
use JSON; | |
######### SMS DARA | |
# regular string building parameters | |
my $secret_code = "666"; | |
my $phone = "09122222222"; | |
my $client = REST::Client->new(); | |
$client->addHeader('Content-Type', 'application/json'); | |
$client->addHeader('charset', 'UTF-8'); | |
$client->addHeader('Accept', 'application/json'); | |
my $req = '{ | |
"UserApiKey" : "aslkfdkjshadfhkashjlkdf", | |
"SecretKey" : "keykey" | |
}'; | |
my $url="https://RestfulSms.com/api/Token"; | |
$client->POST($url, $req); | |
my $text = decode_json($client->responseContent()); | |
my $token = $text->{'TokenKey'} ; | |
$client = REST::Client->new(); | |
$client->addHeader('Content-Type', 'application/json'); | |
$client->addHeader('x-sms-ir-secure-token', $token); | |
$client->addHeader('charset', 'UTF-8'); | |
$client->addHeader('Accept', 'application/json'); | |
# input the template ID taken from your predefined template in their Portal | |
$req = '{"ParameterArray":[{ "Parameter": "VerificationCode","ParameterValue": "' . $secret_code . '"}],"Mobile": "'. $phone .'" ,"TemplateId":"12345"}'; | |
my $url="https://RestfulSms.com/api/UltraFastSend"; | |
$client->POST($url, $req); | |
my $text = decode_json($client->responseContent()); | |
print "Content-type: text/html\n\n"; | |
my $text = "Response: "; #decode_json($client->responseContent()); | |
print $text |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment