API Developer – SMSININDIA

API Developer

SEND SMS

HTTP API

amyntas4sms.in/submitsms.jsp?user=Amyntas&key=d93e8fb55TYU&mobile=91546165654&message=test sms&senderid=INFOSM&accusage=1

Optional Fields:

unicode=1&smstype=flash&time=2015-07-15 15:10:10&idno=2007&TAG=A241&AdsId=1

Account Usage Type

Account TypeValue
Transactional 1
Promotional 2
International 3
OTP6
Other 7

Notes

  • Optional parameters are not compulsory in API.
  • Optional parameters are use for Utility purpose.
    1. Unicode : – This parameter is use when Unicode message is sent.
    2. smstype : – This parameter is use when either normal or flash message is sent.
    3. TAG : – This parameter will be dynamic(varchar).
    4. AdsId : – This parameter is needs to be added with fix value 1.
  • Flash message means pop-up message.
    1. Time : – This parameter is use for scheduling the message.
    2. idno : – This parameter shows Client Id.

XML API

url = amyntas4sms.in/submitsms.jsp?

Add header content-type=application/xml

fields

<parent>

<child>

<user>Amyntas</user>

<key>XXXXXXXXXXX</key>

<mobile>91546165654</mobile>

<message><![CDATA[ Test Message ]]></message>

<accusage>1</accusage>

<senderid>alertp</senderid>

</child>

<child>

<user>Amyntas</user>

<key>XXXXXXXXXX</key>

<mobile>9999999999</mobile>

<message><![CDATA[ Test Message ]]></message>

<accusage>1</accusage>

<senderid>alertp</senderid>

</child>

</parent>

<unicode>1</unicode>

<smstype>flash</smstype>

<time>2015-07-15 15:10:10</time>

<idno>2007</idno>

Response

Text Format

sent,success,123456,2007,91546165654

fail,Invalid key,0,2008,9999999999

Notes

  • Response is shows in above text format.
  • 1st format shows message sent successfully.123456 parameter shows message Id while 2007 parameter shows client id.
  • 2nd format shows message is fail because of Invalid key.

Delivery Report

Request

amyntas4sms.in/getreport.jsp?userid=Amyntas&key=XXXXXXXXXX&sentdate=2015-07-15

Optional Fields:

&messageid=123456&externalid=2007

Response

Mobile number,DLR status,TransactionID(Message Id),Client unique ID,SMS Status,Delivered,Circle,AdsId,TAG name 91546165654,”Available”,”2238765″,”1704518888″,”DELIVRD”,”2019-01-2514:37:30″,”INFOSM”,”BSNL”,”GUJARAT”,”1″,”campaign”

Notes

  • Delivery Report response shows in above format.
  • DELIV parameter shows message is deliver on mobile.
  • EXPIRED parameter shows message is not deliver and also shows the reason.

Get Balance

Request

amyntas4sms.in/getbalance.jsp?user=Amyntas&key=d93e8fb55dXX&accusage=1

Response

1507.0000

Java CODE

import java.io.*;

import java.net.URL;

import java.net.URLConnection;

import java.net.URLEncoder;

public class SendSms{

public static void main(String[] args)

{

//Your user name

String username = “Amyntas”;

//Your authentication key

String authkey = “XXXXXXXXX”;

//Multiple mobiles numbers separated by comma (max 200)

String mobiles = “91546165654”;

//Sender ID,While using route4 sender id should be 6 characters long.

String senderId = “alerts”;

//Your message to send, Add URL encoding here.

String message = “Test message”;

//define route

String accusage=”1″;

//Prepare Url

URLConnection myURLConnection=null;

URL myURL=null;

BufferedReader reader=null;

//encoding message

String encoded_message=URLEncoder.encode(message);

//Send SMS API

String mainUrl=”amyntas4sms.insubmitsms.jsp?”;

//Prepare parameter string

StringBuilder sbPostData= new StringBuilder(mainUrl);

sbPostData.append(“user=”+username);

sbPostData.append(“&key=”+authkey);

sbPostData.append(“&mobile=”+mobiles);

sbPostData.append(“&message=”+encoded_message);

sbPostData.append(“&accusage=”+accusage);

sbPostData.append(“&senderid=”+senderId);

//final string

mainUrl = sbPostData.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();

}

}

}

C# CODE

//Your user name

string user = “Amyntas”;

//Your authentication key

string key = “XXXXXXXXX”;

//Multiple mobiles numbers separated by comma

string mobile = “91546165654”;

//Sender ID,While using route4 sender id should be 6 characters long.

string senderid = “alerts”;

//Your message to send, Add URL encoding here.

string message = HttpUtility.UrlEncode(“Test message”);

//Prepare you post parameters

StringBuilder sbPostData = new StringBuilder();

sbPostData.AppendFormat(“user={0}”, user);

sbPostData.AppendFormat(“&key={0}”, key);

sbPostData.AppendFormat(“&mobile={0}”, mobile);

sbPostData.AppendFormat(“&message={0}”, message);

sbPostData.AppendFormat(“&senderid={0}”, senderid);

sbPostData.AppendFormat(“&accusage={0}”, “1”);

try

{

//Call Send SMS API

string sendSMSUri = “amyntas4sms.insubmitsms.jsp?”;

//Create HTTPWebrequest

HttpWebRequest httpWReq = (HttpWebRequest)WebRequest.Create(sendSMSUri);

//Prepare and Add URL Encoded data

UTF8Encoding encoding = new UTF8Encoding();

byte[] data = encoding.GetBytes(sbPostData.ToString());

//Specify post method

httpWReq.Method = “POST”;

httpWReq.ContentType = “application/x-www-form-urlencoded”;

httpWReq.ContentLength = data.Length;

using (Stream stream = httpWReq.GetRequestStream())

{

stream.Write(data, 0, data.Length);

}

//Get the response

HttpWebResponse response = (HttpWebResponse)httpWReq.GetResponse();

StreamReader reader = new StreamReader(response.GetResponseStream());

string responseString = reader.ReadToEnd();

//Close the response

reader.Close();

response.Close();

}

catch (SystemException ex)

{

MessageBox.Show(ex.Message.ToString());

}

PHP CODE

<?php

$xml_data ='<?xml version=”1.0″?>

<parent>

<child>

<user>demousr</user>

<key>123456XX</key>

<mobile>+91959595XXXX</mobile>

<message>Test SMS 1</message>

<accusage>2</accusage>

<senderid>alertp</senderid>

</child>

<child>

<user>demousr</user>

<key>123456XX</key>

<mobile>+91950000xxxx</mobile>

<message>Test SMS 2</message>

<accusage>2</accusage>

<senderid>alertp</senderid>

</child>

</parent>’;

$URL = “domain/submitsms.jsp?”;

$ch = curl_init($URL);

curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);

curl_setopt($ch, CURLOPT_POST, 1);

curl_setopt($ch, CURLOPT_ENCODING, ‘UTF-8’);

curl_setopt($ch, CURLOPT_HTTPHEADER, array(‘Content-Type: application/xml’));

curl_setopt($ch, CURLOPT_POSTFIELDS, “$xml_data”);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$output = curl_exec($ch);

curl_close($ch);

print_r($output);

?>

VB6 CODE

Private Sub Command1_Click()

Dim DataToSend As String

Dim objXML As Object

Dim message As String

Dim username As String

Dim authKey As String

Dim mobiles As String

Dim sender As String

Dim accusage As String

Dim URL As String

‘Set these variables

username = “Amyntas”;

authKey = “XXXXXXXXX”;

mobiles  = “91546165654”;

‘Sender ID,While using route4 sender id should be 6 characters long.

sender = “alerts”;

‘ this url encode function may not work fully functional.

message = URLEncode(” Your message “)

‘Define route

route = “default”

‘ do not use https

URL = “amyntas4sms.insubmitsms.jsp?”

Set objXML = CreateObject(“Microsoft.XMLHTTP”)

objXML.Open “POST”, URL , False

objXML.setRequestHeader “Content-Type”, “application/x-www-form-urlencoded”

objXML.send “user=” + username +”&key=” + authKey + “&mobile=” + mobiles + “&message=” + message + “&senderid=” + sender + “&accusage=” + accusage

If Len(objXML.responseText) > 0 Then

MsgBox objXML.responseText

End If

End Sub

Function URLEncode(ByVal Text As String) As String

Dim i As Integer

Dim acode As Integer

Dim char As String

URLEncode = Text

For i = Len(URLEncode) To 1 Step -1

acode = Asc(Mid$(URLEncode, i, 1))

Select Case acode

Case 48 To 57, 65 To 90, 97 To 122

‘ don’t touch alphanumeric chars

Case 32

‘ replace space with “+”

Mid$(URLEncode, i, 1) = “+”

Case Else

‘ replace punctuation chars with “%hex”

URLEncode = Left$(URLEncode, i – 1) & “%” & Hex$(acode) & Mid$ _

(URLEncode, i + 1)

End Select

Next

End Function

PHYTON CODE

import urllib # Python URL functions

import urllib2 # Python URL functions

user = “Amyntas” # Your authentication key.

key = “XXXXXXXXX” # Your authentication key.

mobile = “91546165654” # Multiple mobiles numbers separated by comma.

message = “Test message” # Your message to send.

senderid = “alerts” # Sender ID,While using route4 sender id should be 6 characters long.

accusage = “default” # Define route

# Prepare you post parameters

values = {

‘user’ : user,

‘key’ : key,

‘mobile’ : mobile,

‘message’ : message,

‘senderid’ : senderid,

‘accusage’ : accusage

}

url = “amyntas4sms.insubmitsms.jsp?” # API URL

postdata = urllib.urlencode(values) # URL encoding the data here.

req = urllib2.Request(url, postdata)

response = urllib2.urlopen(req)

output = response.read() # Get Response

print output # Print Response

IOS CODE

Private Sub Command1_Click()

Dim DataToSend As String

Dim objXML As Object

Dim message As String

Dim username As String

Dim authKey As String

Dim mobiles As String

Dim sender As String

Dim accusage As String

Dim URL As String

‘Set these variables

username = “Amyntas”;

authKey = “XXXXXXXXX”;

mobiles  = “91546165654”;

‘Sender ID,While using route4 sender id should be 6 characters long.

sender = “alerts”;

‘ this url encode function may not work fully functional.

message = URLEncode(” Your message “)

‘Define route

route = “default”

‘ do not use https

URL = “amyntas4sms.insubmitsms.jsp?”

Set objXML = CreateObject(“Microsoft.XMLHTTP”)

objXML.Open “POST”, URL , False

objXML.setRequestHeader “Content-Type”, “application/x-www-form-urlencoded”

objXML.send “user=” + username +”&key=” + authKey + “&mobile=” + mobiles + “&message=” + message + “&senderid=” + sender + “&accusage=” + accusage

If Len(objXML.responseText) > 0 Then

MsgBox objXML.responseText

End If

End Sub

Function URLEncode(ByVal Text As String) As String

Dim i As Integer

Dim acode As Integer

Dim char As String

URLEncode = Text

For i = Len(URLEncode) To 1 Step -1

acode = Asc(Mid$(URLEncode, i, 1))

Select Case acode

Case 48 To 57, 65 To 90, 97 To 122

‘ don’t touch alphanumeric chars

Case 32

‘ replace space with “+”

Mid$(URLEncode, i, 1) = “+”

Case Else

‘ replace punctuation chars with “%hex”

URLEncode = Left$(URLEncode, i – 1) & “%” & Hex$(acode) & Mid$ _

(URLEncode, i + 1)

End Select

Next

End Function