Real Time Incoming SMS HTTP Forward Bulk SMS API Documnetation

Real Time Incoming SMS HTTP Forward

Receive Incoming SMS Data on your application

Get Incoming SMS Data on your application using HTTP POST method. Once we receive Incoming SMS Data, we forward all the data which we receive from the operator real time. You can capture this response on your website or desired application.

We forward data with POST method.

Sample code given for reference purpose only. Please santize and code properly with all security measures. You need to save the sample code and provide us the URL to forward the request.

 

Key Value Description
Forward Parameters
phonecode 5 to 10 digits long/shortcode This parameter is for availed Longcode or Shortcode number. Example: 56767/9220092200
keyword your approved keyword This is the keyword which was approved from us.
phoneno Recipient Phone Number This is the sender's or recipient's mobile number.
content Recipient Message This is the message when recipient sends to your longcode/shortcode keyword.
location Recipient's Location Recipent's Mobile operator assigned location.
carrier Name of the operator This parameter contains the operator's name.

Save this Page on your Favorite Social Media

Sample Code

<?php
//Save this file as incoming_sms.php
$incomingSMS = new incomingSMS($_REQUEST);

echo $incomingSMS->getPhoneCode();
echo $incomingSMS->getKeyword();
echo $incomingSMS->getPhoneno();
echo $incomingSMS->getContent();
echo $incomingSMS->getLocation();
echo $incomingSMS->getCarrier();

    //or write to a file
    $fp = fopen('incomingsms.csv', 'a');
    fwrite($fp, ".$incomingSMS->getPhoneno().", ".$incomingSMS->getContent()."\r\n"");
    fclose($fp);
    
    //or write to database
    $sgc_db_username = 'yourdatabaseusername';
    $sgc_db_password = 'yourdatabasepassword';
    $sgc_db_name = 'yourdatabasename';
    $sgcsmsc = new mysqli('localhost', $sgc_db_username, $sgc_db_password, $sgc_db_name);
    if($sgcsmsc->connect_errno > 0){
        die('Unable to connect to database [' . $db->connect_error . ']');
    }
    
    $sgcsqlinsert = "INSERT INTO `incoming_sms` (`phoneno`, `content`)
        VALUES ('".$incomingSMS->getPhoneno()."', '".$incomingSMS->getContent()."')";

    if ($sgcsmsc->query($sgcsqlinsert) === TRUE) {
        echo "New record created successfully";
    } else {
        echo "Error: " . $sgcsqlinsert . "<br>" . $sgcsmsc->error;
    }
    $sgcsmsc->close();

//class for incoming sms
class incomingSMS {

    private $phonecode;
    private $keyword;
    private $phoneno;
    private $content;
    private $location;
    private $carrier;

    public function __construct($REQUEST) {
        $this->phonecode = $REQUEST['phonecode'];
        $this->keyword = $REQUEST['keyword'];
        $this->phoneno = $REQUEST['phoneno'];
        $this->content = $REQUEST['content'];
        $this->location = $REQUEST['location'];
        $this->carrier = $REQUEST['carrier'];
    }

    function getPhoneCode() {
        return $this->phonecode;
    }

    function getKeyword() {
        return $this->keyword;
    }

    function getPhoneno() {
        return $this->phoneno;
    }

    function getContent() {
        return $this->content;
    }

    function getLocation() {
        return $this->location;
    }

    function getCarrier() {
        return $this->carrier;
    }
}
We will be updating soon.