Developers

DEVELOPERS

Elite Bulk SMS APIs. Just for Developers

Integrate Bulk SMS APIs Gateway with Java, PHP, HTTP Scripts

<!– Send SMS using XML –>

<MESSAGE>
<AUTHKEY>Authentication Key </AUTHKEY>

<SENDER>SenderID</SENDER>

<ROUTE>Template</ROUTE>

<CAMPAIGN>XML API</CAMPAIGN>

<SMS TEXT=”message1″ >

<ADDRESS TO=”number1″></ADDRESS>

<ADDRESS TO=”number2″></ADDRESS>

</SMS>

<SMS TEXT=”hi test message” >

<ADDRESS TO=”number3″></ADDRESS>

</SMS>

</MESSAGE>

/*Send SMS using JAVA*/

//Your authentication key

String authkey = “YourAuthKey”;

//Multiple mobiles numbers separated by comma

String mobiles = “9999999”;

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

String senderId = “102234”;

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

String message = “Test message”;

//define route

String route=”default”;

//Prepare Url

URLConnection myURLConnection=null;

URL myURL=null;

BufferedReader reader=null;

//encoding message

String encoded_message=URLEncoder.encode(message);

//Send SMS API

String mainUrl=”https://login.yourbulksms.com/api/sendhttp.php?”;

//Prepare parameter string

StringBuilder sbPostData= new StringBuilder(url);

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

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

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

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

sbPostData.append(“&sender=”+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();

}

<?php

/*Send SMS using PHP*/

//Your authentication key

$authKey = “YourAuthKey”;

//Multiple mobiles numbers separated by comma

$mobileNumber = “9999999”;

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

$senderId = “102234”;

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

$message = urlencode(“Test message”);

//Define route

$route = “default”;

//Prepare you post parameters

$postData = array(

‘authkey’ => $authKey,

‘mobiles’ => $mobileNumber,

‘message’ => $message,

‘sender’ => $senderId,

‘route’ => $route

);

//API URL

$url=”https://login.yourbulksms.com/api/sendhttp.php”;

// init the resource

$ch = curl_init();

curl_setopt_array($ch, array(

CURLOPT_URL => $url,

CURLOPT_RETURNTRANSFER => true,

CURLOPT_POST => true,

CURLOPT_POSTFIELDS => $postData

//,CURLOPT_FOLLOWLOCATION => true

));

//Ignore SSL certificate verification

curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);

//get response

$output = curl_exec($ch);

//Print error if any

if(curl_errno($ch))

{

echo ‘error:’ . curl_error($ch);

}

curl_close($ch);

echo $output;

?>

#Send SMS using PYTHON

import urllib # Python URL functions

import urllib2 # Python URL functions

authkey = “YourAuthKey” # Your authentication key.

mobiles = “9999999999” # Multiple mobiles numbers separated by comma.

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

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

route = “default” # Define route

# Prepare you post parameters

values = {

‘authkey’ : authkey,

‘mobiles’ : mobiles,

‘message’ : message,

‘sender’ : sender,

‘route’ : route

}

url = “https://login.yourbulksms.com/api/sendhttp.php” # 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

///Send SMS using C#

//Your authentication key

string authKey = “YourAuthKey”;

//Multiple mobiles numbers separated by comma

string mobileNumber = “9999999”;

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

string senderId = “102234”;

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

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

//Prepare you post parameters

StringBuilder sbPostData = new StringBuilder();

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

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

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

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

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

try

{

//Call Send SMS API

string sendSMSUri = “https://login.yourbulksms.com/api/sendhttp.php”;

//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());

}

//Windows SMS API integration code

try

{

string strResult = “”;

//Prepare you post parameters

var postValues = new List<KeyValuePair<string, string>>();

//Your authentication key

postValues.Add(new KeyValuePair<string, string>(“authkey”, “YourAuthKey”));

//Multiple mobiles numbers separated by comma

postValues.Add(new KeyValuePair<string, string>(“mobiles”, “9999999”));

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

postValues.Add(new KeyValuePair<string, string>(“sender”, “102234”));

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

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

postValues.Add(new KeyValuePair<string, string>(“message”, message));

//Select route

postValues.Add(new KeyValuePair<string, string>(“route”,”default”));

//Prepare API to send SMS

Uri requesturl = new Uri(“https://login.yourbulksms.com/api/sendhttp.php”);

//create httpclient request

var httpClient = new HttpClient();

var httpContent = new HttpRequestMessage(HttpMethod.Post, requesturl);

httpContent.Headers.ExpectContinue = false;

httpContent.Content = new FormUrlEncodedContent(postValues);

HttpResponseMessage response = await httpClient.SendAsync(httpContent);

//Get response

var result = await response.Content.ReadAsStringAsync();

strResult = result.ToString();
response.Dispose();
httpClient.Dispose();
httpContent.Dispose();
}
catch (Exception ex)
{
throw ex;
}

//Android SMS API integration code

//Your authentication key
String authkey = “YourAuthKey”;
//Multiple mobiles numbers separated by comma
String mobiles = “9999999”;
//Sender ID,While using route4 sender id should be 6 characters long.
String senderId = “102234”;
//Your message to send, Add URL encoding here.
String message = “Test message”;
//define route
String route=”default”;

URLConnection myURLConnection=null;
URL myURL=null;
BufferedReader reader=null;

//encoding message
String encoded_message=URLEncoder.encode(message);

//Send SMS API
String mainUrl=”https://login.yourbulksms.com/api/sendhttp.php?”;

//Prepare parameter string
StringBuilder sbPostData= new StringBuilder(mainUrl);
sbPostData.append(“authkey=”+authkey);
sbPostData.append(“&mobiles=”+mobiles);
sbPostData.append(“&message=”+encoded_message);
sbPostData.append(“&route=”+route);
sbPostData.append(“&sender=”+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
Log.d(“RESPONSE”, “”+response);

//finally close connection
reader.close();
}
catch (IOException e)
{
e.printStackTrace();
}

//IOS SMS API integration code
//Create Objects
NSMutableData * responseData;
NSURLConnection * connection;
// In your viewDidLoad method add this lines
-(void)viewDidLoad
{
[super viewDidLoad];
//Your authentication key
NSString * authkey = @”YourAuthKey”;
//Multiple mobiles numbers separated by comma
NSString * mobiles = @”9999999″;
//Sender ID,While using route4 sender id should be 6 characters long.
NSString * senderId = @”102234″;
//Your message to send, Add URL encoding here.
NSString * message = @”Test message”;
//define route
NSString * route = @”default”;
// Prepare your url to send sms with this parameters.
NSString * url = [[NSString stringWithFormat:@”https://login.yourbulksms.com/api/sendhttp.php?authkey=%@&mobiles=%@&message=%@&sender=%@&route=%@”, authkey, mobiles, message, senderId, route] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSURLRequest * request = [NSURLRequest requestWithURL:[NSURL URLWithString:url]];
connection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
}
// implement URLConnection Delegate Methods as follow
-(void) connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
{
//Get response data
responseData = [NSMutableData data];
}
-(void) connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
[responseData appendData:data];
}
-(void) connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@”Error” message:error.localizedDescription delegate:self cancelButtonTitle:nil otherButtonTitles:@”OK”, nil];
[alert show];
}
-(void) connectionDidFinishLoading:(NSURLConnection *)connection
{
// Get response data in NSString.
NSString * responceStr = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
}

‘VB6 SMS API integration code

Private Sub Command1_Click()
Dim DataToSend As String
Dim objXML As Object
Dim message As String
Dim authKey As String
Dim mobiles As String
Dim sender As String
Dim route As String
Dim URL As String

‘Set these variables
authKey = “Your auth key”;

mobiles  = “9999999999”;

‘Sender ID,While using route4 sender id should be 6 characters long.
sender = “TESTIN”;

‘ this url encode function may not work fully functional.

message = URLEncode(” Your message “)

‘Define route
route = “default”
‘ do not use https
URL = “https://login.yourbulksms.com/api/sendhttp.php?”

Set objXML = CreateObject(“Microsoft.XMLHTTP”)
objXML.Open “POST”, URL , False
objXML.setRequestHeader “Content-Type”, “application/x-www-form-urlencoded”

objXML.send “authkey=” + authKey + “&mobiles=” + mobiles + “&message=” + message + “&sender=” + sender + “&route=” + route

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

import java.io.*;
import java.net.URL;
import java.net.HttpURLConnection;

class Functions
{

public static String hitUrl(String urlToHit, String param)
{
try
{
URL url = new URL(urlToHit);
HttpURLConnection http = (HttpURLConnection)url.openConnection();
http.setDoOutput(true);
http.setDoInput(true);
http.setRequestMethod(“POST”);

DataOutputStream wr = new DataOutputStream(http.getOutputStream());
wr.writeBytes(param);
wr.flush();
wr.close();
http.disconnect();

BufferedReader in = new BufferedReader(new InputStreamReader(http.getInputStream()));
String inputLine;
if ((inputLine = in.readLine()) != null)
{
in.close();
return inputLine;
}
else
{
in.close();
return “-1”;
}

}
catch(Exception e)
{
System.out.println(“Exception Caught..!!!”);
e.printStackTrace();
return “-2”;
}
}
}

public class HitXmlData
{
public static void main(String[] args)
{
String strUrl = “https://login.yourbulksms.com/api/postsms.php”;
String xmlData = “data=
<MESSAGE>
<AUTHKEY>YOURAUTHKEY</AUTHKEY>
<ROUTE>default</ROUTE>
<SMS TEXT=’message1 testing’ FROM=’AAAAAA’>
<ADDRESS TO=’9999999990′></ADDRESS>
</SMS>
</MESSAGE>”

String output = Functions.hitUrl(strUrl, xmlData);
System.out.println(“Output is: “+output);
}
}