What is HTTP API in Bulk SMS and Sample API Codes in different languages?

What is HTTP API in Bulk SMS and Sample API Codes in different languages? post thumbnail image

Bulk SMS API is a string, plays an important role to integrate any application to messaging platform. It secure your data and protects your application or software to access with proper mobile authentication. Mobile number authenticated through the OTP (One Time Password) verification. This is the example of HTTP String :

https://bulksmsindia.app/V2/http-api.php?apikey=xxxxxxxxxxxxxxxxx&senderid=xxxxxx&number=xxxxxxxxxx,xxxxxxxxxxX&message=hello

This API is showing different parameters, like apikey, sender id, number and message. These are variable and need to enter the variables while sending SMS. This is a highly secure and easy to integrate into any application. Here we have given different use cases of the Bulk SMS API.
1. Two factor authentication.
2. OTP(One Time Password) Login.
3. Mobile Number Verification.
4. Opt-in Subscription.
5. Retrieve Password.
6. Registration confirmation and many more.

We would like to introduce different types of Bulk SMS API to be configured according to the requirement of applications as the different applications are developed in different playtform. These APIs helps you to integrate your application according to requirement. SMS Service provider or vendor provides SMS API according to customers requirement, below are the sample codes for different languages :

*******SAMPLE CODE : PHP*******

$sender =’XXXX’;
$mob =’XXXXX’;
$auth=’Your auth key’;
$msg = urlencode(“test”);

$url = ‘http://202.143.96.204/API/sms-api.php?auth=’.$auth.’&msisdn=’.$mob.’&senderid=’.$sender.’&message=’.$msg.’;  // API URL

$result=SendSMS($url);  // call function that return response with code
echo $result;

//function define
function SendSMS($hostUrl){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $hostUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_POST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); // change to 1 to verify cert
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
//curl_setopt($ch, CURLOPT_USERPWD, “$username:$password”);
$result = curl_exec($ch);
return $result;
}

*******SAMPLE CODE : ASP.NET*******

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;

using System.IO;
using System.Net;

public void SMSSend()
{
WebClient client = new WebClient();
string baseurl = “https://bulksmsindia.app/V2/http-api.php?apikey=xxxxxxxxxxxxxxxxxxxx&senderid=xxxxxx&number=xxxxxxxxxx&message=hello“;
Stream data = client.OpenRead(baseurl);
StreamReader reader = new StreamReader(data);
string s = reader.ReadToEnd();
data.Close();
reader.Close();
}

*******SAMPLE CODE : ASP*******        

sResponse = SMSSend(pno, message )
If right(sResponse,15) = “Send Successful” Then
‘write your code here
End If

Function SMSSend (strPh,strMsg)

Dim msgResponse
Dim strRequest
Dim strUrl
msgResponse = “”

strPh=right(strPh,10)
If not IsNumeric(strPh) Or len(strPh) <> 10 Then
msgResponse = “Enter valid Mobile Number.”
End If
If strMsg = “” Then
msgResponse = “Enter text message.”
End If

strUrl = “https://bulksmsindia.app/V2/http-api.php?”
strRequest = strRequest+”apikey=xxxxxxxxxxxxxxxxxxxx”
strRequest = strRequest+”&senderid=sender”
strRequest = strRequest+”&number=”+strPh
strRequest = strRequest+”&message=”+Server.URLEncode(strMsg)

strUrl = strUrl+strRequest

If msgResponse = “” Then
Dim oXML
Dim sPage
Err.Clear
On Error Resume Next
Set oXML = Server.CreateObject(“Msxml2.XMLHTTP”)
oXML.Open “get”, strUrl , false
oXML.Send
msgResponse = oXML.ResponseText
Set oXML = Nothing
End If

SMSSend = msgResponse

If Err.Number <> 0 Then
SMSSend = “Problem on sending sms : “& Err.Description
End If

End Function

*******SAMPLE CODE : PYTHON*******

import http.client
conn = http.client.HTTPSConnection(“bulksmsindia.app”)
headers = {
‘cache-control’: “no-cache”
}
conn.request(“GET”, “/V2/http-api.php?apikey=xxxxxxxxxxxxxxxxxxxx&senderid=xxxxxx&number=xxxxxxxxxx&message=hello”, headers=headers)
res = conn.getresponse()
data = res.read()
print(data.decode(“utf-8”))

*******SAMPLE CODE : NODE JS*******

var request = require (“request”);
var options = { method: ‘GET’,
  url: ‘https://bulksmsindia.app/V2/http-api.php?‘,
  qs:
   {
apikey: ‘xxxxxxxxxxxxxxxxxxxx’,
    senderid: ‘xxxxxx’,
    number: ‘xxxxxxxxxx’,
    message: ‘hello’
  },
  strictSSL: false,
  rejectUnauthorized: false,
  headers:
   {
  ‘cache-control’: ‘no-cache’ }
   };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});


*******SAMPLE CODE : JAVA*******


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import java.util.Date;

public class SMSSend {
public static void main(String[] args)
{ try {
Date mydate = new Date(System.currentTimeMillis());

URL url = new URL(“https://bulksmsindia.app/V2/http-api.php?apikey=xxxxxxxxxxxxxxxxxxxx&senderid=xxxxxx&number=xxxxxxxxxx&message=hello“);
HttpURLConnection conn = (HttpURLConnection)url.openConnection();
conn.setRequestMethod(“GET”);
conn.setDoOutput(true);
conn.setDoInput(true);
conn.setUseCaches(false);
conn.connect();
BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String line;
StringBuffer buffer = new StringBuffer();
while ((line = rd.readLine()) != null)
{
buffer.append(line).append(“\n”);
}
System.out.println(buffer.toString());
rd.close();
conn.disconnect();
}catch(Exception e)
{e
.printStackTrace();
}
}}
Note: Required javax.servlet.jar and jdom.jar to execute (downloadable from internet,add to classpath).

*******SAMPLE CODE : C#*******

var client = new RestClient(“https://bulksmsindia.app/V2/http-api.php?apikey=xxxxxxxxxxxxxxxxxxxx&senderid=xxxxxx&number=xxxxxxxxxx&message=hello“);
var request = new RestRequest(Method.POST);
request.AddHeader(“cache-control”, “no-cache”);
IRestResponse response = client.Execute(request);


Leave a Reply

Your email address will not be published. Required fields are marked *