– Want to get a sms message when someone send a feedback on your website?
– Want to send a confirmation SMS when your user submit an order on your website?
– Want to send a notification SMS when your users order being delivered?
– Want to trigger an application when receive an incoming SMS message?

 

The answer to the above questions are SMS Gateway.

SMS gateway is an appliance or a software to interface with computer program or web site program, to forward the message to the users mobile phone through SMS messages.

Compare to email, SMS message is faster and more reliable way to communicate to your user.

 

sms_gateway
GT Notify SMS Gateway

HTTP API To Send Out SMS

The most simple way is using HTTP method, just a simple HTTP statement can trigger a SMS message to be sent out to the user’s mobile phone. This command can be triggered from the browser, or from a php script.

Example URL Request:

http://gtnotify_ip_address/index.php?md=smsapi&num=98764321&msg=helloworld&pass=xxxxxx
Field NameField Description
numPhone Number
msgMessage
passGT Notify password

Note: for the phone number with country code + in the url, the url needs to encode the + sign to %2B.

http://gtnotify_ip_address/index.php?md=smsapi&num=%2B6598764321&msg=helloworld&pass=xxxxxx

SMS OTP (One Time Password)

Using GT Notify SMS Gateway to send out OTP (One Time Password),  to make your application with 2FA (2 Factor Authentication) capability. It simple to integrate and very flexible to use.

Step 1, Request OTP:

http://gtnotify_ip_address/api.php?md=otp_request&num=91459742&pass=xxxxx

Return value:

{"status":"Success","value":6}

Step 2. Verify OTP:

http://gtnotify_ip_address/api.php?md=otp_verify&request_id=6&pin=477166&pass=xxxxx

Return value:

{"status":"Success","value":"0"}

Email To  SMS

Want to send out a SMS by send a email? This is another function of GT Notify.  Just point your domain (eg. abc.com) MX record to GT Notify SMS Gateway. Then send a email to mobile_number@abc.com.

GT Notify SMS gateway will send out the SMS message to the mobile_number, the message will be like subject : message.

Example:

You send out a email :

Email address: 91459742@abc.com

Email subject: Hello World

Email content: This is a testing message

 

GT Notify SMS Gateway will send out SMS message.

To: 91459742

Message: Hello World : This is a testing message

 


SMS to Email

Want to forward the incoming SMS message to a email address? GT Notify SMS Gateway SMS to Email function will do that.

 

Just enable the SMS to Email functions, and enter the email configuration information on the setup.

When SMS is received, the GT Notify SMS will forward the SMS to a predefined email address.

Example:

The GT Notify SMS gateway received a SMS from mobile phone : 914597542, the message is “Hello World”

You want the incoming SMS send to a email admin@abc.com

GT Notify SMS gateway will forward the SMS to that email address like the following:

To Address : admin@abc.com

Subject : SMS received from : 91459742

Content : Hello World



Web Hook ( Passing Incoming SMS to Other Applications)

From GT Notify system, user can configure web hook to let the GT Notify system to pass the received message information (in json format) to other applications through HTTP Post.

GT Web Hook

  • The Json data file have 3 fields: Date,  Phone,  Msg
  • The application should receive and process the Json data, following is an example php code for receiving the Json data, decode the content, and insert into the database.
  • The result will be written to system log file, so user can check the status of the transaction.

 

Sample PHP code to process the web hook Json data and insert into database.

<?php 
//define the database connection 
$host_name = ‘localhost’; 
$db_user = ‘xxxxx; 
$db_password = ‘xxxxxx’; 
$db_name = ‘xxxxxx’; 
$db_conn = mysqli_connect($host_name, $db_user, $db_password, $db_name); 

//receive the json data and decode the data into array $data 

$data = file_get_contents(“php://input”); $data = json_decode($data, True); 
//Insert $data[Date], $data[Phone], $data[Msg] into database 

$sql = “INSERT INTO gt_webhook (date, phone, msg) values (‘$data[Date]’,’$data[Phone]’,’$data[Msg]’)”; 
$ret = mysqli_query($db_conn,$sql); 
?>

API to add subscriber into GT Notify  (api_addsub_json)

Application can send the json file to GT Notify and create a GT subscriber directly.

GT Notify recognise the following json file format:

 

 

Field NameField Description
numSubscriber phone number
nameSubscriber name
gpGroup Name
fd1FD1 (flexible field)
fd2FD1 (flexible field)
fd3FD1 (flexible field)
fd4FD1 (flexible field)
noteNotes
passGT Notify Password

 

Sample code:


<?php
$url = "http://192.168.1.172/index.php?md=api_addsub_json";
$authToken = '123456';
$data = array(
 'name' => 'John Low',
 'num' => '844856230',
 'gp' => 'Retail',
 'fd1' => 'testing fd1',
 'fd2' => 'testing fd2',
 'fd3' => 'testing fd3',
 'fd4' => 'testing fd4',
 'note' => 'notes field',
 'pass' => 'Notify',
);

$data_string = json_encode($data);

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
 'Content-Type:application/json',
 'Content-Length: ' . strlen($data_string) ,
 'API-TOKEN-KEY:'.$authToken )); // API-TOKEN-KEY is keyword so change according to ur key word. like authorization

// execute the request
//$output = curl_exec($ch);

echo $output;

// Check for errors
if($output === FALSE){
 die(curl_error($ch));
 $message = curl_error($ch);
 echo $message;
}

// close curl resource to free up system resources

curl_close($ch);
?>


API to send SMS using json file  (api_sendsms_json)

Application can send SMS through json file to GT Notify.

GT Notify recognise the following json file format:

Field NameField Description
dateScheduled Date
timeScheduled Time
numPhone Numbers separate by comma
msgMessage
intervalinterval seconds between each SMS send out
passGT Notify password

Sample code:


<?php
$url = "http://192.168.1.80/index.php?md=api_sendsms_json";
$data = array(
"date" => '',
"time" => '',
"num" => '96462561,96462562,96462563,96462564',
"msg" => 'Hello World!',
"interval" => '5',
"pass" => 'Notify');

// json encode data
$authToken = "12345678";
$data_string = json_encode($data);
// set up the curl resource
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type:application/json',
'Content-Length: ' . strlen($data_string) ,
'API-TOKEN-KEY:'.$authToken )); // API-TOKEN-KEY is keyword so change according to ur key word. like authorization

//execute the request
$output = curl_exec($ch);
//echo $output;
// Check for errors
if($output === FALSE){
die(curl_error($ch));
echo $curl_error($ch);
}
echo($output) . PHP_EOL;
// close curl resource to free up system resources
curl_close($ch);

<?php>