HTTP SMS API
Send SMS using HTTP API
HTTP API To Send SMS (New)
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:
Field Name | Description | Example |
---|---|---|
user | user name | john |
pass | password | xyz123 |
num | mobile number | 98765432 |
msg | message | Hello World |
Note: for the phone number with country code + in the url, the url needs to encode the + sign to %2B.
HTTP API To Send SMS (Old)
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:
Field Name | Field Description |
---|---|
num | Phone Number |
msg | Message |
pass | GT Notify password |
Note: for the phone number with country code + in the url, the url needs to encode the + sign to %2B.
HTTP API to send SMS using json (api_sendsms_json)
Application can send SMS through json file to GT Notify.
GT Notify recognise the following json file format:
Field Name | Field Description |
---|---|
date | Scheduled Date |
time | Scheduled Time |
num | Phone Numbers separate by comma |
msg | Message |
interval | interval seconds between each SMS send out |
pass | GT 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);
?>