Pingbix SMS
Pingbix SMS API enables you a seamless configuration, set up and delivery of SMS across the globe. This section of API is divided in to 2 sub categories; Global SMS and Alerts(India). Below is the SMS API Documentation.
How can I use this API?
PHP Sample Code
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://app.pingbix.com/SMSApi/send",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "userid=XXXXXX&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_HTTPHEADER => array(
"apikey: somerandomuniquekey",
"cache-control: no-cache",
"content-type: application/x-www-form-urlencoded"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
<?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_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 #:" . $err;
} else {
echo $response;
}xx
JAVA Sample Code
package test;
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);
// Request parameters and other properties.
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"));
params.add(new BasicNameValuePair("time", "2018-09-16 13:24:00"));
params.add(new BasicNameValuePair("senderid", "SENDER"));
params.add(new BasicNameValuePair("test", "false"));
params.add(new BasicNameValuePair("dltEntityId", "xxxxxxxxxxxxx"));
params.add(new BasicNameValuePair("dltTemplateId", "xxxxxxxxxxxxx"));
params.add(new BasicNameValuePair("duplicatecheck", "true"));
params.add(new BasicNameValuePair("output", "json"));
params.add(new BasicNameValuePair("group", "name1,name2,id1,id2"));
httppost.setEntity(new UrlEncodedFormEntity(params, "UTF-8"));
// Execute and get the response.
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"));
}
}
}
}
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 apikey key
String apiKey = "YourApiKey";
// OR
String userId = "TopRewards";
String password = "YourPassword";
// Message type text/unicode/flash
String msgType = "text";
// Multiple Group Names/IDs separated by comma
String group = "name1,name2,id1,id2";
// 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) {
// TODO Auto-generated catch block
System.out.println("Exception while encoding msg");
e1.printStackTrace();
}
// API End Point
String mainUrl = "https://app.pingbix.com/SMSApi/send?";
// API Paramters
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);
// final string
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)
// print response
System.out.println(response);
// finally close connection
reader.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
Send SMS Phonebook
Send SMS Batch
PHP Sample Code
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://app.pingbix.com/SMSApi/send",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "userid=TopRewards&password=xxxxx&mobile=91xxxxxxxxxx&msg=Hello+World%21+This+is+a+test+message%21&senderid=SENDER&msgType=text&dltEntityId=xxxxxxxxxxxxx&dltTemplateId=xxxxxxxxxxxxx&duplicatecheck=true&output=json&sendMethod=quick",
CURLOPT_HTTPHEADER => array(
"apikey: somerandomuniquekey",
"cache-control: no-cache",
"content-type: application/x-www-form-urlencoded"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://app.pingbix.com/SMSApi/send?userid=xxxxx&password=xxxxx&mobile=91xxxxxxxxxx&msg=Hello+World%21+This+is+a+test+message%21&senderid=SENDER&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 #:" . $err;
} else {
echo $response;
}
JAVA Sample Code
package test;
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);
// Request parameters and other properties.
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"));
params.add(new BasicNameValuePair("time", "2018-09-16 13:24:00"));
params.add(new BasicNameValuePair("senderid", "SENDER"));
params.add(new BasicNameValuePair("test", "false"));
params.add(new BasicNameValuePair("dltEntityId", "xxxxxxxxxxxxx"));
params.add(new BasicNameValuePair("dltTemplateId", "xxxxxxxxxxxxx"));
params.add(new BasicNameValuePair("duplicatecheck", "true"));
params.add(new BasicNameValuePair("output", "json"));
params.add(new BasicNameValuePair("mobile", "91xxxxxxxxxx"));
httppost.setEntity(new UrlEncodedFormEntity(params, "UTF-8"));
// Execute and get the response.
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"));
}
}
}
}
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 apikey key
String apiKey = "YourApiKey";
// OR
String userId = "xxxxx";
String password = "YourPassword";
// Message type text/unicode/flash
String msgType = "text";
// Multiple mobiles numbers separated by comma
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) {
// TODO Auto-generated catch block
System.out.println("Exception while encoding msg");
e1.printStackTrace();
}
// API End Point
String mainUrl = "https://app.pingbix.com/SMSApi/send?";
// API Paramters
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);
// final string
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)
// print response
System.out.println(response);
// finally close connection
reader.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
PHP Sample Code
<?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;
}
File Upload
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;
}
}