HTTP API Details :

Send SMS :

http://mshastra.com/sendurlcomma.aspx? user=profileid&pwd=password& senderid=ABC&CountryCode=91& mobileno=9999999989,9999999990,9999999991& msgtext=Hello&smstype=0/4/3

*smstype : 0 = Transactional-1,3 = Transactional Optin,4 = Promotional,13 = Transactional OTP,9 = Transactional-2

Check Balance :

http://mshastra.com/balance.aspx?user=profileid&pwd=password

ASP Code Sample : (Send SMS)

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 = “http://mshastra.com/sendurlcomma.aspx?”
strRequest = strRequest+”user=profileid”
strRequest = strRequest+”&pwd=pass”
strRequest = strRequest+”&senderid=senderid”
strRequest = strRequest+”&mobileno=”+strPh
strRequest = strRequest+”&msgtext=”+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

ASP .NET (C#) Code Sample : (Send SMS)

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 = “http://mshastra.com/sendurlcomma.aspx?user=profileid&pwd=xxxx&senderid=ABC&CountryCode=91&mobileno=9911111111&msgtext=Hello”;
Stream data = client.OpenRead(baseurl);
StreamReader reader = new StreamReader(data);
string s = reader.ReadToEnd();
data.Close();
reader.Close();
}

ASP .NET (VB.NET) Code Sample : (Send SMS)

Public Class Form1

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

Dim strPh As String
Dim strMsg As String
Dim msgResponse
Dim msgRes As String
Dim strRequest As String
Dim strUrl
Dim server
strRequest = “”
msgResponse = “”

strPh = Trim(txtMoNumber.Text)
strMsg = Trim(txtMessage.Text)

strUrl = “http://mshastra.com/sendurl.aspx?”
strRequest = strRequest + “&user=200*****”
strRequest = strRequest + “&pwd=********”
strRequest = strRequest + “&senderid=ABCXYZ”
strRequest = strRequest + “&mobileno=” + strPh
strRequest = strRequest + “&msgtext=” + System.Uri.EscapeDataString(strMsg)
strRequest = strRequest + “&CountryCode=ALL”

strUrl = strUrl + strRequest

MsgBox(strUrl)

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

End If

End Sub
End Class

Java Code Sample : (Send SMS)

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(“http://mshastra.com/sendurlcomma.aspx?user=profileid&pwd=xxxx&senderid=ABC&CountryCode=91&mobileno=9911111111&msgtext=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 ).

PHP Code Sample : (Send SMS)

‘– Use URLEncode for parameter msgtext
?php
$url = “http://mshastra.com/sendurlcomma.aspx?user=profileid&pwd=xxxx&senderid=ABC&CountryCode=91&mobileno=9911111111&msgtext=Hello”;
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$curl_scraped_page = curl_exec($ch);
curl_close($ch);
echo $curl_scraped_page;
?

Python Code Sample : (Send SMS)

import urllib3 # Python URL functions
from urllib.parse import quote_plus

http = urllib3.PoolManager()

user = “username” # Your username key.
pwd = “password” # Define password
senderid = “112233” # Sender ID,While using route4 sender id should be 6 characters long.
countrycode = “91” # country code.
mobileno = “9999999999” # mobile number
msgtext = “Test message” # Your message to send.

msgtext = quote_plus(msgtext) # URL encoding the data here.

# Prepare you post parameters
values = {
‘user’ : user,
‘pwd’ : pwd,
‘senderid’ : senderid,
‘CountryCode’ : countrycode,
‘mobileno’ : mobileno,
‘msgtext’ : msgtext
}

url = “http://mshastra.com/sendurl.aspx” # API URL
postdata = values
req = http.request(‘POST’,url, postdata)
print (req.data) # Print Response