Developers API

GET

http://clientlogin.bulksmsgh.com/smsapi?key=xxxxx&to=xxxxx&msg=xxxxx&sender_id=xxxxx
Parameters Required Type Description
API key Yes String Login to your dashboard and create one
to Yes String Contacts message will be sent to
msg Yes String The message you want to send
sender_id Yes String An id to identify the sender of the message. eg: BulkSMS Ghana

Below are sample codes in PHP,Java and Python on how to use our API

$key="3cc0d30dfd925d7b554f" //your unique API key;
$message=urlencode($message) //encode url;
/*******************API URL FOR SENDING MESSAGES********/
$url="http://clientlogin.bulksmsgh.com/smsapi?key=$key&to=$phone&msg=$message&sender_id=$sender_id";
/****************API URL TO CHECK BALANCE****************/
$url="http://clientlogin.bulksmsgh.com/api/smsapibalance?key=$key";

$result=file_get_contents($url); //call url and store result;

switch($result){
case "1000":
echo "Message sent";
break;
case "1002":
echo "Message not sent";
break;
case "1003":
echo "You don't have enough balance";
break;
case "1004":
echo "Invalid API Key";
break;
case "1005":
echo "Phone number not valid";
break;
case "1006":
echo "Invalid Sender ID";
break;
case "1008":
echo "Empty message";
break;
}

import java.net.*;
import java.io.*;

/**
*
* @author BulkSMS Ghana
*/
public class SendMessage {

public static void main(String[] args) throws Exception {
String API_key = “3cc0d30dfd925d7b554f”;
String message = “Sending SMS has never been this fun!”;
String phone_number = “02xxxxxxxx”;
String sender_id = “xxxxxxxxxx”; //11 characters

/*******************API URL FOR SENDING MESSAGES********/
URL url = new URL(“http://clientlogin.bulksmsgh.com/smsapi?key=” + API_key + “&to=” + phone_number + “&msg=” + message + “&sender_id=” + sender_id);

/****************API URL TO CHECK BALANCE****************/
URL url = new URL(“http://clientlogin.bulksmsgh.com/api/smsapibalance?key=” + API_key);

URLConnection connection = url.openConnection();
BufferedReader in = new BufferedReader(new  InputStreamReader(connection.getInputStream()));
String inputLine;
inputLine = in.readLine().trim();
if (inputLine.equals(“1000”)) {
System.out.println(“Message sent”);
} else if (inputLine.equals(“1002”)) {
System.out.println(“Message not sent”);
} else if (inputLine.equals(“1003”)) {
System.out.println(“You don’t have enough balance”);
} else if (inputLine.equals(“1004”)) {
System.out.println(“Invalid API Key”);
} else if (inputLine.equals(“1005”)) {
System.out.println(“Phone number not valid”);
} else if (inputLine.equals(“1006”)) {
System.out.println(“Invalid Sender ID”);
} else if (inputLine.equals(“1008”)) {
System.out.println(“Empty message”);
}
in.close();
}
}

#!/usr/bin/env python
import urllib2
import urllib

def send_sms(api_key,phone,message,sender_id):
#parameters to send SMS
params = {“key”:api_key,”to”:phone,”msg”:message,”sender_id”:sender_id}
#url to send SMS

/*******************API URL FOR SENDING MESSAGES********/
url = ‘http://clientlogin.bulksmsgh.com/smsapi?’+ urllib.urlencode(params)

/****************API URL TO CHECK BALANCE****************/
url = ‘http://clientlogin.bulksmsgh.com/api/smsapibalance?’+ urllib.urlencode(api_key)

content = urllib2.urlopen(url).read()

#Interpreting codes obtained from reading the URL
if(content.strip() == ‘1000’) :
print “Message successfully sent”
elif(content.strip() == ‘1002’) :
print “Message not sent”
elif(content.strip() == ‘1003’) :
print “Your balance is not enough”
elif(content.strip() == ‘1004’) :
print “Invalid API Key”
elif(content.strip() == ‘1005’) :
print “Phone number not valid”
elif(content.strip() == ‘1006’) :
print “Invalid sender id”
elif(content.strip() == ‘1008’) :
print “Empty message”

#Defining variables to be used inside function
api_key = ‘3cc0d30dfd925d7b554f’ #API Key generated from your account
phone = ’02xxxxxx’ #SMS recepient’s phone number
message = ‘xxxxxxxxxxxxxxxxxxxxx’ #Message to be sent
sender_id = ‘xxxxxxxxxxxx’ #Sender id for the message

#Calling function that was created to send sms
send_sms(api_key,phone,message,sender_id)