loader

Bulk SMS API

EASILY INTEGRATE ANY APPLICATION AND START SENDING SMS IN MINUTES. ACCESS SAMPLE CODES IN PHP, JAVA, .NET & MORE.

SECURE, SCALABLE & POWERFUL BULK SMS APIS

YourBulkSMS APIs allow you to send bulk SMS offers, trigger transactional updates and OTPs, receive inbound SMS, pull reports, manage contacts & more. Our intelligent SMS gateway routing assures best-in-class delivery. Our API is developed for custom integration with your application. With high flexibility and robustness, it can be easily integrated to work in any kind of environment.

<?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=”http://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;
?>

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 = “http://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

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 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=”http://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
System.out.println(response);

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

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);
// use wr.write(param.getBytes(“UTF-8”)); for unicode message’s instead of 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 = “http://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);

}

}

//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 = “http://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());
}

//write this code in your .gs file
//Your authentication key
var authKey = “YourAuthKey”;

//Multiple mobiles numbers separated by comma
var mobileNumber = “9999999”;

//Sender ID,While using route4 sender id should be 6 characters long.
var senderId = “102234”;

//Your message to send, Add URL encoding here.
var message = “Test message”;

//Define route
var route = “default”;


var payload = {
“authkey”: authKey,
‘mobiles’ : mobileNumber,
‘message’ : message,
‘sender’ : senderId,
‘route’ : route
};

var options = {
“method”: “post”,
“payload”: payload
};

var res = UrlFetchApp.fetch(“http://login.yourbulksms.com/api/sendhttp.php?”, options);

var resAsTxt = ” + res + ”;

Logger.log(resAsTxt)

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(“http://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;
}

//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=”http://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();
}

//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:@”http://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];
}

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 = “http://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

set define off;

CREATE OR REPLACE PACKAGE sms_api IS

FUNCTION send_sms(mobiles IN VARCHAR2,
message IN VARCHAR2,
sender IN VARCHAR2,
route IN PLS_INTEGER,
country IN PLS_INTEGER,
flash IN PLS_INTEGER,
unicode IN PLS_INTEGER,
schtime IN VARCHAR2,
campaign IN VARCHAR2,
response IN VARCHAR2 DEFAULT ‘text’,
authkey IN VARCHAR2 DEFAULT ‘Your auth key’)
RETURN VARCHAR2;

END sms_api;
/

CREATE OR REPLACE PACKAGE BODY sms_api IS

FUNCTION get_clobFromUrl(p_url VARCHAR2) RETURN CLOB IS
req utl_http.req;
resp utl_http.resp;
val VARCHAR2(32767);
l_result CLOB;
BEGIN
req := utl_http.begin_request(p_url);
resp := utl_http.get_response(req);
LOOP
utl_http.read_line(resp, val, TRUE);
l_result := l_result || val;
END LOOP;
utl_http.end_response(resp);
RETURN l_result;
EXCEPTION
WHEN utl_http.end_of_body THEN
utl_http.end_response(resp);
RETURN l_result;
WHEN OTHERS THEN
utl_http.end_response(resp);
RAISE;
END;

FUNCTION send_sms(mobiles IN VARCHAR2,
message IN VARCHAR2,
sender IN VARCHAR2,
route IN PLS_INTEGER,
country IN PLS_INTEGER,
flash IN PLS_INTEGER,
unicode IN PLS_INTEGER,
schtime IN VARCHAR2,
campaign IN VARCHAR2,
response IN VARCHAR2 DEFAULT ‘text’,
authkey IN VARCHAR2 DEFAULT ‘Your auth key’)
RETURN VARCHAR2 IS
l_url VARCHAR2(32000) := ‘http://login.yourbulksms.com/api/sendhttp.php’;
l_result VARCHAR2(32000);
BEGIN
l_url := l_url || ‘?authkey=’ || authkey;
l_url := l_url || ‘&mobiles=’ || mobiles;
l_url := l_url || ‘&message=’ || message;
l_url := l_url || ‘&sender=’ || sender;
l_url := l_url || ‘&route=’ || route;
l_url := l_url || ‘&country=’ || country;
l_url := l_url || ‘&flash=’ || flash;
l_url := l_url || ‘&unicode=’ || unicode;
IF schtime IS NOT NULL THEN
l_url := l_url || ‘&schtime=’ || schtime;
END IF;
l_url := l_url || ‘&response=’ || response;
l_url := l_url || ‘&campaign=’ || campaign;
l_url := utl_url.escape(l_url);
l_result := get_clobFromUrl(l_url);
RETURN l_result;
END;

END sms_api;
/

package main

import (
“fmt”
“strings”
“net/url”
“net/http”
“io/ioutil”
)

func main() {

message := “Hi hello ho & #42 *&23 w are you….”


urlToPost := “http://login.yourbulksms.com/api/sendhttp.php”


form := url.Values{}
form.Add(“authkey”, “You AuthKey”)
form.Add(“mobiles”, “9999999999”)
form.Add(“message”, message)
form.Add(“sender”, “ALERTS”)
form.Add(“route”, “4”)

fmt.Println(form.Encode())

req, _ := http.NewRequest(“POST”, urlToPost, strings.NewReader(form.Encode()))

req.Header.Add(“Content-Type”, “application/x-www-form-urlencoded”)

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)

fmt.Println(res)
fmt.Println(string(body))

}

For reseller account write a mail at sales@yourbulksms.com

Articles

Our Latest Blog