Our SMS API, simply, easy

HTTP API

This page provides a reference for all features available to you via the HTTP interface for sending SMS.
The HTTP-API allows you to integrate your system (client) to Easy Send SMS using the HTTP protocol to send SMS. HTTPS is also supported for secure transactions using SSL encryption.
The Client issues either a HTTP GET or POST request to the Easy Send SMSHTTP interface supplying a list of required parameters. Our system issues back a HTTP response which indicates the status of the sent message.
The HTTP-API is used for one-way messaging only. Therefore, you need to provide a valid the Sender ID of the message to enable the recipient to respond.

ParameterDescriptionPresence
userYour Easy Send SMS usernameMandatory
passwordYour Easy Send SMS passwordMandatory
fromSender Name that the message will appear from.

 Max Length of 18 if numeric.
 Max Length of 11 if alphanumeric.
To prefix the plus sign (+) to the sender’s address when the message is displayed on their cell phone, please prefix the plus sign to your sender’s address while submitting the message (note the plus sign should be URL encoded). Additional restrictions on this field may be enforced by the SMSC.
Mandatory
toMSIDSN of the recipient that the message will be sent to. Eg: 61409317436 (Do not use + before the country code)Mandatory
textThe message to be sent. It can be used for 'long' messages, that is, messages longer than 160 characters for plain text, 140 for flash and 280 for Unicode. For concatenated (long) messages every 153 characters are counted as one message for plain text and 268 characters for Unicode, as the rest of the characters will be used by the system for packing extra information for re-assembling the message on the cell phoneMandatory
TypeIt indicates the type of message. Values for type include:

0: Plain text (GSM 3.38 Character encoding)
1: Unicode
2: Flash (GSM 3.38 Character encoding)
3: Unicode Flash

(160 characters for plain text, 140 for flash and 280 for Unicode. For concatenated (long) messages every 153 Route Mobile Limited © 2018. All rights reserved 4 Request Parameters characters are counted as one message for plain text and 268 characters for Unicode, as the rest of the characters will be used by the system for packing extra information for re-assembling the message on the cell phone. )
Mandatory

 

HTTP Response

The HTTP response from our system contains the following:

  • Status Code
  • Sent OK Message ID (Internal use only)
  • SMS ID
  • Error message (if present)

 

Status Codes

If the message has been sent successfully the status code will return OK: 0

 

Example:
OK:1234567891011

If the message was unable to be delivered it will return ERROR: {Error code}

 

Example:
ERROR:1001

 

Examples

Below are example requests when using the HTTP interface.

 

Example Send Single SMS (English)

Username: testuser

Password: secret

From: Test

To: 103333333333

Text: Hello World

Type: 0

 

Request:
https://www.easysendsms.com/sms/bulksms-api/bulksms-api?username=testuser&password=secret&from=Test&to=12345678910&text=Hello%20world&type=0
Output:
OK:1234567890123 

 


Example Send To Multi Numbers ( Bulk SMS )

https://www.easysendsms.com/sms/bulksms-api/bulksms-api?username=testuser&password=secret&from=Test&to=12345678910,12345678910,12345678910,12345678910,12345678910&text=Hello%20world&type=0

A request containing multiple destinations will be aborted immediately if any error other than “Invalid Destination” is found. In case an invalid destination is found we just skip that destination and proceed to the next destination, maximum you can send 50 numbers per submission

Output:
OK:1234567890123,OK:1234567890123,OK:1234567890123,OK:1234567890123 


Example Send Single SMS ( Unicode )

https://www.easysendsms.com/sms/bulksms-api/bulksms-api?username=testuser&password=secret&from=Test&to=12345678910&text=006500610073007900730065006E00640073006D0073002E0063006F006D&type=1

calling the above link by replacing the username and password by your account credentials, you should get the SMS ‘easysendsms.com’ on the mobile number in the destination field. The message has to be encoded on the UTF-16BE format and the type parameter has to be set to (type=1).

Output:
OK:1234567890123 


Status Codes

 

ParameterDescription
delivrdThe message has been received by the handset.
expiredThe carrier has timed out.
undelivThe messages failed to reach the handset.

 

Information on Unicode

Error Codes

 

ParameterDescription
1001Invalid URL. This means that one of the parameters was not provided or left blank.
1002Invalid username or password parameter.
1003Invalid type parameter.
1004Invalid message.
1005Invalid mobile number.
1006Invalid sender name.
1007Insufficient credit.
1008Internal error (do NOT re-submit the same message again).
1009Service not available (do NOT re-submit the same message again).

Call The API By Code

Calling HTTP API using .NET

Imports System.IO

Imports System.Net

Imports System.Data

Partial Class SendUsingHTTP

Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e

As System.EventArgs) Handles Me.Load

Dim WebRequest As Net.WebRequest    'object for WebRequest 

Dim WebResonse As Net.WebResponse 'object for WebResponse

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''

' DEFINE PARAMETERS USED IN URL

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''

'To what server you need to connect to for submission

Dim Server As String = "easysendsms.com"

'Username that is to be used for submission

Dim UserName As String = ""

' password that is to be used along with username

Dim Password As String = ""

'What type of the message

'0:means plain text

'1:means unicode (Message content should be in Hex)

'2:means plain text Flash

'3:means Unicode Flash(Message content should be in Hex)

 

Dim type As Integer = 0

'Message content that is to be transmitted

Dim Message As String = "Test Message"

'Url Encode message

Message = HttpUtility.UrlEncode(Message)

If (Message = 0) Or (Message = 2) Then Message = ConvertToUnicode(Message)

End If

'Sender Name to be used for submitting the message

Dim From As String = ""

'To which mobile number is to be sent for more than one number should be comma separated Like 'xxxxxxx,xxxxxxx

Dim To As String = ""

'''''''CODE COMPLETE TO DEFINE PARAMETER''''''''''''''''

Dim WebResponseString As String = ""

Dim URL As String = "https://" & Server &

api?username=" & UserName & "&password=" & Password &

"&type=" & type  "&To=" & To &

"&From=" &From & "&message=" & Message & ""

 WebRequest = Net.HttpWebRequest.Create(URL) 'Hit URL Link

 WebRequest.Timeout = 25000

Try

WebResonse = WebRequest.GetResponse 'Get Response

Dim reader As IO.StreamReader = New

IO.StreamReader(WebResonse.GetResponseStream)

'Read Response and store in variable

WebResponseString = reader.ReadToEnd() WebResonse.Close()

Response.Write(WebResponseString) 'Display Response.

Catch ex As Exception

WebResponseString = "Request Timeout" 'If any exception occurs.

Response.Write(WebResponseString)

End Try

End Sub

'Function To Convert String to Unicode if Type=1 and 3. 

Public Function ConvertToUnicode(ByVal str As String) As String Dim

ArrayOFBytes() As Byte = System.Text.Encoding.Unicode.GetBytes(str)

Dim UnicodeString As String = ""

Dim v As Integer

 

For v = 0 To ArrayOFBytes.Length - 1

If v Mod 2 = 0 Then

Dim t As Integer = ArrayOFBytes(v)

 ArrayOFBytes(v) = ArrayOFBytes(v + 1)

ArrayOFBytes(v + 1) = t

End If 

Next

 

For v = 0 To ArrayOFBytes.Length - 1

Dim c As String = Hex$(ArrayOFBytes(v))

If c.Length = 1 Then c = "0" & c

End If

UnicodeString = UnicodeString & c

Next

 

Return UnicodeString

End Function

End Class 

Calling HTTP API using PHP

 <?Php Class Sender{ Var $Host; Var $Port;

/*

Username That Is To Be Used For Submission

*/

 

Var $StrUserName;

 

/*

Password That Is To Be Used

*/

 

Var $StrPassword;

 

/*

Sender Name To Be Used For Submitting The Message

*/

Var $StrSender;

 

/*

Message Content That Is To Be Transmitted

*/

Var $StrMessage;

 

/*

Mobile No Is To Be Transmitted.

*/

 

Var $StrMobile;

 

 /*

Type Of The Message That Is To Be Sent

 

0:Means Plain Text

1:Means Unicode (Message Content Should Be In Hex)

2:Means Plain Flash Text

3:Means Unicode Flash (Message Content Should Be In Hex)

*/

Var $StrMessageType;

 

Private Function Sms__Unicode($Message){

 

$Hex1='';

 

If (Function_Exists('Iconv')) {

 

$Latin = @Iconv('UTF-8', 'ISO-8859-1', $Message); If (Strcmp($Latin, $Message)) {

 

$Arr = Unpack('H*Hex', @Iconv('UTF-8', 'UCS-2BE',

 

$Message));

 

$Hex1 = Strtoupper($Arr['Hex']);

 

}

 

If($Hex1 ==''){

 

$Hex2='';

 

$Hex='';

 

For ($I=0; $I < Strlen($Message); $I++)

 

{

 

$Hex = Dechex(Ord($Message[$I]));

 

$Len =Strlen($Hex); $Add = 4 - $Len;  If($Len < 4)

 

{ For($J=0;$J<$Add;$J++)

 

{ $Hex="0".$Hex;

 

} }

 

$Hex2.=$Hex;

 

}

 

Return $Hex2;

 

} Else{ Return $Hex1; } }  Else{

 

Print 'Iconv Function Not Exists !';

 

}

} 

 

$Message,$Mobile, $Msgtype){

$This->Host=$Host;

$This->StrUserName = $Username;

$This->StrPassword = $Password;

$This->StrSender= $Sender;

$This->StrMessage=$Message; //URL Encode The Message..

$This->StrMobile=$Mobile;

$This->StrMessageType=$Msgtype;

}

 

Public Function Submit(){

 

If($This->StrMessageType=="1" || $This->StrMessageType=="3") {

 

//Call The Function Of String To HEX.

$This->StrMessage = $This->Sms__Unicode($This->StrMessage); Try{

 

//Http Url To Send Sms.

 

$Live_Url="Https://".$This->Host."/api?Username=".$This->StrUserName."&Password=".$This->StrPassword."&Type=".$This >StrMessageType

 

"&To=".$This->StrMobile."&From=".$This-

 

>StrSender."&Message=".$This-

 

>StrMessage.""; $Parse_Url=File($Live_Url); Echo $Parse_Url[0];  }Catch(Exception $E){

 

Echo 'Message:' .$E->GetMessage();

 

}

 

} Else

 

$This>StrMessage=Urlencode($This->StrMessage); Try{

 

// Http Url To Send Sms.

 

$Live_Url="Https://".$This->Host.

 

"/Api?Username=".$This-

 

>StrUserName."&Password=".$This->StrPassword."&Type=".$This-

 

>StrMessageType."&To=".$This-

 

>StrMobile."&From=".$This-

 

>StrSender."&Message=".$This-

 

>StrMessage."";

 

$Parse_Url=File($Live_Url); Echo $Parse_Url[0];

 

}

 

Catch(Exception $E){

 

Echo 'Message:' .$E->GetMessage();

 

}

 

} }

 

$Obj = New Sender("IP","","","Tester"," ""," Xxxxxxx

 

,"2","1");

 

$Obj->Submit ();

 

?>

Calling HTTP API using Java

import java.io.BufferedReader;

import  java.io.DataOutputStream;

import  java.io.InputStreamReader; import java.net.HttpURLConnection;

import java.net.URL;

import java.net.URLEncoder;

 

/**

*  An Example Class to use for the submission using HTTP API you can perform * your own validations into this Class For username, password,To,

*  From, type, message, server 

**/

public class Sender {

// Username that is to be used for submission

String username;

// password that is to be used along with username

String password;

// Message content that is to be transmitted

String message;

/**

*  What type of the message that is to be sent *

 

*0:means plain text

*  1:means flash

*  2:means Unicode (Message content should be in Hex)

*  6:means Unicode Flash (Message content should be in Hex)

*  

*/

 

/**

*  To which mobile number to be sent ,for submitting more than one number at once should be comma separated

Like

*  xxxxxxx,xxxxxxx */

String To;

 

// Sender name to be used 

String From;

// To what server you need to connect 

String server;

 

public Sender(String server,String username, String password, String message, String dlr, String type, String To, String From) { this.username = username; this.password = password; this.message = message; this.type = type;

this.To = To; this.From = From; this.server = server; this.port = port;

}

private void submitMessage() {

 

try {

// Url that will be called to submit the message

URL sendUrl = new URL("http://" + this.server + ":" + this.port

+ "/bulksms/bulksms");

HttpURLConnection httpConnection = (HttpURLConnection) sendUrl

.openConnection();

// This method sets the method type to POST so that

// will be send as a POST request

httpConnection.setRequestMethod("POST");

// This method is set as true which we intend to send

// input to the server

httpConnection.setDoInput(true);

// This method implies that we intend to receive data from server. httpConnection.setDoOutput(true);

// Implies do not use cached data

httpConnection.setUseCaches(false);

// Data that will be sent over the stream to the server. 

DataOutputStream dataStreamToServer = new DataOutputStream( httpConnection.getOutputStream());

dataStreamToServer.writeBytes("username="

+ URLEncoder.encode(this.username, "UTF-8") + "&password="

+ URLEncoder.encode(this.password, "UTF-8") + "&type="

+ URLEncoder.encode(this.dlr, "UTF-8") + "&To="

+ URLEncoder.encode(this.To, "UTF-8") + "&From="

+ URLEncoder.encode(this.From, "UTF-8") + "&message="

+ URLEncoder.encode(this.message, "UTF-8")); dataStreamToServer.flush(); dataStreamToServer.close();

// Here take the output value of the server.

BufferedReader

dataStreamFromUrl = new BufferedReader( new InputStreamReader(httpConnection.getInputStream()));

String dataFromUrl = "", dataBuffer = "";

// Writing information from the stream to the buffer

while ((dataBuffer = dataStreamFromUrl.readLine()) != null) { dataFromUrl += dataBuffer;

}

/**

* Now dataFromUrl variable contains the Response received from the * server so we can parse the response and process it accordingly.

*/

dataStreamFromUrl.close();

System.out.println("Response: " + dataFromUrl);

} catch (Exception ex) { ex.printStackTrace();

}

}

public static void main(String[] args) { try {

// Below example is for sending Plain text

Sender s = new Sender("easysednssms.com", "tester909",

"test11", "test for unicode", "1", "0", "xxxxxxx",

"Update");

s.submitMessage();

// Below example is for sending unicode

Sender s1 = new Sender("easysendsms.com", "xxxx",

"xxx", convertToUnicode("test for unicode").toString(),

"1", "1", "xxxxxxx", "Update"); s1.submitMessage();

} catch (Exception ex) {

}

}

 

/* *

*  Below method converts the unicode to hex value

*  @param regText

*  @return

*/

 

private static StringBuffer convertToUnicode(String regText) {

 char[] chars = regText.toCharArray(); StringBuffer hexString = new StringBuffer();

For (int i = 0; i < chars.length; i++) {

String iniHexString = Integer.toHexString((int) chars[i]);

If (iniHexString.length() == 1) iniHexString = "000" + iniHexString;

else if (iniHexString.length() == 2) iniHexString = "00" + iniHexString;

else if (iniHexString.length() == 3) iniHexString = "0" + iniHexString;

hexString.append(iniHexString);

}

System.out.println(hexString);

return hexString;

} }