SMS API

Simplify messaging for your business with Pingbix's reliable, scalable, and feature-rich SMS API.
Send messages seamlessly, manage contacts efficiently, and integrate effortlessly into your platform.

Step-by-step guide on how to integrate and optimize your SMS API setup with Pingbix for efficient messaging.

PHP Sample Code - Send SMS Phonebook

cURL (POST)
<?php
      
$DeliveryReport = new DeliveryReport($_REQUEST);
      
echo $DeliveryReport->getMobile();
echo $DeliveryReport->getErrorCode();
echo $DeliveryReport->getDoneTime();
echo $DeliveryReport->getReceivedTime();
echo $DeliveryReport->getTransId();
  echo $DeliveryReport->getMsgId();
      
      // or insert to database
      
      class DeliveryReport {
          
      private $transId;
      private $msgId;
      private $errorCode;
      private $doneTime;
      private $receivedTime;
      private $mobile;
        
            public function __construct($REQUEST) {
        
        // sanitize data
        $this->transId       = $REQUEST['transId'];
        $this->msgId         = $REQUEST['msgId'];
          $this->errorCode     = $REQUEST['errorCode'];
           $this->doneTime      = $REQUEST['doneTime'];
                $this->receivedTime  = $REQUEST['receivedTime'];
                $this->mobile        = $REQUEST['mobile'];
            }
        
            function getTransId() {
                return $this->transId;
            }
        
            function getMsgId() {
                return $this->msgId;
            }
        
            function getErrorCode() {
                return $this->errorCode;
            }
        
            function getDoneTime() {
                return $this->doneTime;
            }
        
            function getReceivedTime() {
                return $this->receivedTime;
            }
        
            function getMobile() {
                return $this->mobile;
            }
        
        }
              
cURL (GET)
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
    CURLOPT_URL => "https://app.pingbix.com/SMSApi/send?userid=XXXX&password=xxxxx&group=name1%2Cname2%2Cid1%2Cid2&msg=Hello+World%21+This+is+a+test+message%21&senderid=SENDER&msgType=text&dltEntityId=xxxxxxxxxxxxx&dltTemplateId=xxxxxxxxxxxxx&duplicatecheck=true&output=json&sendMethod=group",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_HTTPHEADER => array(
        "cache-control: no-cache"
    ),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
    echo "cURL Error #: " . $err;
} else {
    echo $response;
}
          

JAVA Sample Code - Send SMS Phonebook

JAVA (POST)
            import java.io.IOException;
            import java.io.InputStream;
            import java.util.ArrayList;
            import java.util.List;
          
            import org.apache.http.HttpEntity;
            import org.apache.http.HttpResponse;
            import org.apache.http.NameValuePair;
            import org.apache.http.client.ClientProtocolException;
            import org.apache.http.client.HttpClient;
            import org.apache.http.client.entity.UrlEncodedFormEntity;
            import org.apache.http.client.methods.HttpPost;
            import org.apache.http.impl.client.HttpClients;
            import org.apache.http.message.BasicNameValuePair;
            import org.apache.http.util.EntityUtils;
          
            public class SendMessage {
              public static void main(String[] args) 
                throws ClientProtocolException, IOException {
                
                String ServerDomain = "https://app.pingbix.com/SMSApi/send";
                String ApiEndPoint = "/send";
          
                HttpClient httpclient = HttpClients.createDefault();
                HttpPost httppost = new HttpPost(ServerDomain + ApiEndPoint);
          
                List<NameValuePair> params = new ArrayList<NameValuePair>(2);
                params.add(new BasicNameValuePair("userid", "admin"));
                params.add(new BasicNameValuePair("password", "YourPassword"));
                params.add(new BasicNameValuePair("text", "Hello World"));
                params.add(new BasicNameValuePair("type", "text"));
                
                httppost.setEntity(new UrlEncodedFormEntity(params, "UTF-8"));
          
                HttpResponse response = httpclient.execute(httppost);
                HttpEntity entity = response.getEntity();
          
                System.out.println("StatusCode: " + response.getStatusLine().getStatusCode());
          
                if (entity != null) {
                  try (InputStream instream = entity.getContent()) {
                    System.out.println(EntityUtils.toString(entity, "utf-8"));
                  }
                }
              }
            }
          
JAVA (GET)
            import java.io.*;
            import java.net.URL;
            import java.net.URLConnection;
            import java.net.URLEncoder;
          
            public class SMSGateway {
              public static void main(String[] args) {
                String apiKey = "YourApiKey";
                String userId = "TopRewards";
                String password = "YourPassword";
                String msgType = "text";
                String group = "name1,name2,id1,id2";
                String senderId = "SENDER";
                String msg = "This is a test message in Java";
                String dltEntityId = "xxxxxxxxxxxxx";
                String dltTemplateId = "xxxxxxxxxxxxx";
                String output = "json";
          
                URLConnection myURLConnection = null;
                URL myURL = null;
                BufferedReader reader = null;
          
                String urlencodedmsg = "";
                try {
                  urlencodedmsg = URLEncoder.encode(msg, "UTF-8");
                } catch (UnsupportedEncodingException e1) {
                  System.out.println("Exception while encoding msg");
                  e1.printStackTrace();
                }
          
                String mainUrl = "https://app.pingbix.com/SMSApi/send?";
          
                StringBuilder sendSmsData = new StringBuilder(mainUrl);
                sendSmsData.append("apikey=" + apiKey);
                sendSmsData.append("userid=" + userId);
                sendSmsData.append("password=" + password);
                sendSmsData.append("type=" + msgType);
                sendSmsData.append("group=" + group);
                sendSmsData.append("senderid=" + senderId);
                sendSmsData.append("text=" + urlencodedmsg);
                sendSmsData.append("dltEntityId=" + dltEntityId);
                sendSmsData.append("dltTemplateId=" + dltTemplateId);
                sendSmsData.append("output=" + output);
                mainUrl = sendSmsData.toString();
          
                try {
                  myURL = new URL(mainUrl);
                  myURLConnection = myURL.openConnection();
                  myURLConnection.connect();
                  reader = new BufferedReader(new InputStreamReader(myURLConnection.getInputStream()));
                  String response;
                  while ((response = reader.readLine()) != null)
                    System.out.println(response);
                  reader.close();
                } catch (IOException e) {
                  e.printStackTrace();
                }
              }
            }
          

PHP Sample Code - Send SMS Batch

cURL (POST)
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
    CURLOPT_URL => "https://app.pingbix.com/SMSApi/send?userid=XXXX&password=xxxxx&group=name1%2Cname2%2Cid1%2Cid2&msg=Hello+World%21+This+is+a+test+message%21&senderid=SENDER&msgType=text&dltEntityId=xxxxxxxxxxxxx&dltTemplateId=xxxxxxxxxxxxx&duplicatecheck=true&output=json&sendMethod=group",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_HTTPHEADER => array(
        "cache-control: no-cache"
    ),
));
    $response = curl_exec($curl);
    $err = curl_error($curl);
    curl_close($curl);
    if ($err) {
        echo "cURL Error #: " . $err;
    } else {
        echo $response;
    }
cURL (GET)
<?php
$curl = curl_init();
curl_setopt_array($curl, arrspan>(
    CURLOPT_URL => "https://app.pingbix.com/SMSApi/send?userid=xxamp;password=xxxxx&mobile=91xxxxxxxxxx&msg=Hello+World%21+This+is+a+test+message%21&senderid=SENamp;msgType=text&dltEntityId=xxxxxxxxxxxxx&dltTemplateId=xxxxxxxxxxxxx&duplicatecheck=true&output=json&sendMethod=quick",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => "GET",
    CURLOPT_HTTPHEADER => array(
        "cache-control: no-cache"
    ),
));
    $response = curl_exec($curl);
    $err = curl_error($curl);
    curl_close($curl);
    if ($err) {
        echo "cURL Error #:" . $espan>;
    } else {
        echo $response;
    }

JAVA Sample Code - Send SMS Batch

JAVA (POST)
            import java.io.*;
            import java.net.URL;
            import java.net.URLConnection;
            import java.net.URLEncoder;
          
            public class SendMessage {
              public static void main(String[] args) throws IOException {
                String serverDomain = "https://app.pingbix.com/SMSApi/send";
                String apiEndpoint = "/send";
          
                String userId = "admin";
                String password = "YourPassword";
                String message = "Hello World";
                String msgType = "text";
                String senderId = "SENDER";
                String dltEntityId = "xxxxxxxxxxxxx";
                String dltTemplateId = "xxxxxxxxxxxxx";
                String output = "json";
                String mobile = "91xxxxxxxxxx";
          
                // Prepare the URL connection.
                StringBuilder requestUrl = new StringBuilder(serverDomain + apiEndpoint);
                requestUrl.append("?userid=").append(userId);
                requestUrl.append("&password=").append(password);
                requestUrl.append("&msg=").append(message);
                requestUrl.append("&type=").append(msgType);
                requestUrl.append("&senderid=").append(senderId);
                requestUrl.append("&dltEntityId=").append(dltEntityId);
                requestUrl.append("&dltTemplateId=").append(dltTemplateId);
                requestUrl.append("&output=").append(output);
                requestUrl.append("&mobile=").append(mobile);
          
                // Execute the request
                URL myURL = new URL(requestUrl.toString());
                URLConnection connection = myURL.openConnection();
                BufferedReader reader = new BufferedReader(
                  new InputStreamReader(connection.getInputStream())
                );
          
                String responseLine;
                while ((responseLine = reader.readLine()) != null) {
                  System.out.println(responseLine);
                }
                reader.close();
              }
            }
          
JAVA (GET)
            import java.io.*;
            import java.net.URL;
            import java.net.URLConnection;
            import java.net.URLEncoder;
          
            public class SMSGateway {
              public static void main(String[] args) {
                // Your API key
                String apiKey = "YourApiKey";
                // OR
                String userId = "xxxxx";
                String password = "YourPassword";
          
                // Message type: text/unicode/flash
                String msgType = "text";
          
                // Multiple mobile numbers separated by commas
                String mobile = "91999xxxxxxx";
                // Your approved sender ID
                String senderId = "SENDER";
                // Your message to terminate (URLEncode the content)
                String msg = "This is a test message in Java";
                // DLT PE ID
                String dltEntityId = "xxxxxxxxxxxxx";
                // DLT Template ID
                String dltTemplateId = "xxxxxxxxxxxxx";
                // Response format
                String output = "json";
          
                // Prepare URL
                URLConnection myURLConnection = null;
                URL myURL = null;
                BufferedReader reader = null;
          
                // URL encode message
                String urlencodedmsg = "";
                try {
                  urlencodedmsg = URLEncoder.encode(msg, "UTF-8");
                } catch (UnsupportedEncodingException e1) {
                  System.out.println("Exception while encoding msg");
                  e1.printStackTrace();
                }
          
                // API Endpoint
                String mainUrl = "https://app.pingbix.com/SMSApi/send?";
          
                // API Parameters
                StringBuilder sendSmsData = new StringBuilder(mainUrl);
                sendSmsData.append("apikey=" + apiKey);
                sendSmsData.append("&userid=" + userId);
                sendSmsData.append("&password=" + password);
                sendSmsData.append("&type=" + msgType);
                sendSmsData.append("&mobile=" + mobile);
                sendSmsData.append("&senderid=" + senderId);
                sendSmsData.append("&text=" + urlencodedmsg);
                sendSmsData.append("&dltEntityId=" + dltEntityId);
                sendSmsData.append("&dltTemplateId=" + dltTemplateId);
                sendSmsData.append("&output=" + output);
          
                mainUrl = sendSmsData.toString();
          
                try {
                  // Prepare connection
                  myURL = new URL(mainUrl);
                  myURLConnection = myURL.openConnection();
                  myURLConnection.connect();
                  reader = new BufferedReader(
                    new InputStreamReader(myURLConnection.getInputStream())
                  );
          
                  // Reading response
                  String response;
                  while ((response = reader.readLine()) != null) {
                    System.out.println(response);
                  }
          
                  // Close connection
                  reader.close();
                } catch (IOException e) {
                  e.printStackTrace();
              }
          }
      }
          

PHP Sample Code - File Upload

PHP (POST)
  <?php
  $curl = curl_init();
  curl_setopt_array($curl, array(
    CURLOPT_URL => "https://app.pingbix.com/SMSApi/send/file",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => "POST",
    CURLOPT_POSTFIELDS => "------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"userid\"\r\n\r\nTopRewards\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"password\"\r\n\r\nxxxxxxxx\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"file\"; filename=\"sample.csv\"\r\nContent-Type: text/csv\r\n\r\n\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"text\"\r\n\r\nHello World! This is a test message.\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"type\"\r\n\r\ntext\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"time\"\r\n\r\n2019-07-15 00:00:00\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"senderid\"\r\n\r\nTESTIN\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"duplicatecheck\"\r\n\r\ntrue\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"output\"\r\n\r\njson\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW--",
    CURLOPT_HTTPHEADER => array(
      "Content-Type: application/x-www-form-urlencoded",
      "apikey: ",
      "cache-control: no-cache",
      "content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW"
    ),
  ));
  $response = curl_exec($curl);
  $err = curl_error($curl);
  curl_close($curl);
  if ($err) {
    echo "cURL Error #:" . $err;
  } else {
    echo $response;
  }

PHP Sample Code - Call Back DLR Script

PHP Sample Code
<?php

$DeliveryReport = new DeliveryReport($_REQUEST);

echo $DeliveryReport->getMobile();
echo $DeliveryReport->getErrorCode();
echo $DeliveryReport->getDoneTime();
echo $DeliveryReport->getReceivedTime();
echo $DeliveryReport->getTransId();
echo $DeliveryReport->getMsgId();

// or insert to database

class DeliveryReport {
    private $transId;
    private $msgId;
    private $errorCode;
    private $doneTime;
    private $receivedTime;
    private $mobile;

    public function __construct($REQUEST) {
        // sanitize data
        $this->transId = $REQUEST['transId'];
        $this->msgId = $REQUEST['msgId'];
        $this->errorCode = $REQUEST['errorCode'];
        $this->doneTime = $REQUEST['doneTime'];
        $this->receivedTime = $REQUEST['receivedTime'];
        $this->mobile = $REQUEST['mobile'];
    }

    function getTransId() {
        return $this->transId;
    }

    function getMsgId() {
        return $this->msgId;
    }

    function getErrorCode() {
        return $this->errorCode;
    }

    function getDoneTime() {
        return $this->doneTime;
    }

    function getReceivedTime() {
        return $this->receivedTime;
    }

    function getMobile() {
        return $this->mobile;
    }
}

Frequently Asked Questions About SMS API

How do I set up SMS messaging with Pingbix?

To get started, create an account on Pingbix and follow the integration guide to implement the SMS API on your platform.

Are there restrictions on the number of SMS messages I can send?

While Pingbix does not impose limits, some carriers may have message volume and frequency restrictions based on regulations.

What measures are in place to protect my SMS data?

Pingbix employs high-level encryption protocols to secure all SMS communications, ensuring your data remains private and protected from unauthorized access.