Application Programme Interface (API)

G-bulksms gives you the priviledge to send SMS while not visiting the web site through its powerful Application Programme Interface (API). With the API you can send SMS from a Standalone Application, web Application, Mobile Application, Website, etc. In addition to that you can check your balance from the api.

In order to use the API, you need to signup. If you have already registered here you can now login to the bulk SMS account.

Click here if you have not registered.

SEND SMS
You can also seperate each recipient number by comma.

https://www.gbulksms.com/api/sendsms?key=your_Api_key&username=your_User_name&to=Recipient_Phonenumber&from=originator&message=sms_message_body
&type=message_type&route=routeid

SCHEDULE SMS

https://www.gbulksms.com/api/schedulesms?key=your_Api_key&username=your_User_name&to=Recipient_Phonenumber&from=originator&message=sms_message_body
&type=message_type&date=datevalue&time=timevalue

CHECK BALANCE

https://www.gbulksms.com/api/balance?key=your_API_key&username=your_user_name&balance=true

ACCEPTED PARAMETERS
Parameter Description Examples
Key This stands for API key. Check your API by the right side of the admin dashboard window. 80e7e7cbewirf5cdedj1ff52a8d225bf4b7b
to Phone number of the recipient that the message will be sent to. +2348123456789
from SenderID (if alphanumeric, max 11 characters) gbulksms
message Message to be sent. Hi Test sms recieved from gbulksms.com
username Your loggin username. gbulksms-1
type The type of message to be delivered either plain text or unicode. By default the type is 0 for plain text, you can type 1 as an alternative for unicode text. 0
route This is applicable to nigerians only. The route there signifies either you are sending sms to phone number not on DND or phone number on DND. The route for sending sms to number on DND is 1 but for numbers not on DND is 0 1
region This is a two letter abbreviation of each country codes. You can find your region by clicking here. NG
date This stands for the schedule date. The format here is yyyy-MM-dd. 06/14/2017
time This stands for the schedule time. The format here is hh:mm ampm. 2:20 PM

SERVER RESPONSES

Below is the list of the server reponses and their meanings:

OK = Successful.

2906 = SMS Sending failed or invalid entry.

2907 = Gateway unavailable.

2908 = Recipient is empty or invalid.

2909 = Sender is empty or invalid.

2903 = Username is empty or invalid.

2910 = Message is empty or invalid.

2904 = Key is empty or invalid.

2905 = Authentication error.

2901 = No Network Coverage.

2902 = Date is empty or invalid.

2912 = Time is empty or invalid.

SCREEN SHOT OF SERVER RESPONSE
g-bulksms screen shot server repsonse for fail g-bulksms screen shot server repsonse for success
CODE EXAMPLES FOR SENDING SMS
<?php
	// Simple SMS send function
	function sendSMS($your_API_key, $your_user_name, $recipient_phonenumber, $originator, $message, $message_type, $routeid) {
        $URL = "https://www.gbulksms.com/api/sendsms?key=" . $your_API_key . "&to=" . $recipient_phonenumber
        ."&message=".$message.'&from='.$originator.'&.'&username='.$your_user_name"&type=" . $message_type"&route=" . $route_id;
		$fp = fopen( $URL, 'r' );
		return fread( $fp, 1024 );
	}
	// Example of use 
	$response = sendSMS('80e7e7cbewirf5cdedj1ff52a8d225bf4b7b', 'gbulksms-1', '+2348123456789', 'G-Bulksms', 'Hello', '0', '1');
	echo $response;
?>
<?php
    // Simple SMS send function
    function sendSMS($your_API_key, $your_user_name, $recipient_phonenumber, $originator, $message, $message_type, $routeid) {
        $URL = "https://www.gbulksms.com/api/sendsms?key=" . $your_API_key . "&to=" . $recipient_phonenumber
        ."&message=".$message.'&from='.$originator.'&.'&username='.$your_user_name.'&type='.$message_type.'&route='.$routeid;
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $URL);
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        $output = curl_exec($ch);
        $info = curl_getinfo($ch);
        curl_close($ch);
        return $output;
    }
    // Example of use
    $response = sendSMS('80e7e7cbewirf5cdedj1ff52a8d225bf4b7b', 'gbulksms-1', '+2348123456789', 'G-Bulksms', 'Hi Test sms recieved from gbulksms.com', '0', '1');
    echo $response ;
?>
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
// Uses Apache Common URL utils, download from apache.org and put it in CLASSPATH
import org.apache.commons.codec.binary.Base64;

// Simple send SMS programm
public class SendSMS {
    public static String sendSMS( String your_API_key, String your_user_name, String Recipient_phonenumber , String message , String originator , String message_type , String routeid ) {
		
        String webPage;
        try {
            webPage = "https://www.gbulksms.com/api/sendsms?key=" + your_API_key + 
                "&to=" + Recipient_phonenumber + "&message=" + message +
                "&from=" + originator + "&username=" + your_user_name+"&type=" + message_type+"&route=" + routeid;
        } catch ( UnsupportedEncodingException e ) {
            return "UnsupportedEncodingException";
        }

		try{
			URL url = new URL(webPage);
			URLConnection urlConnection = url.openConnection();

			InputStream is = urlConnection.getInputStream();
			InputStreamReader isr = new InputStreamReader(is);

			int numCharsRead;
			char[] charArray = new char[1024];
			StringBuffer sb = new StringBuffer();

			while ((numCharsRead = isr.read(charArray)) > 0) {
				sb.append(charArray, 0, numCharsRead);
			}
			String result = sb.toString();
			return result;		

		} catch ( Exception e ){
			return "MalformedURLException";
		}
    }

    public static void main( String[] args ){
        // Example of use 
        String response = sendSMS( "80e7e7cbewirf5cdedj1ff52a8d225bf4b7b", "gbulksms-1","+2348123456789" , "Hi Test sms recieved from gbulksms.com" , "gbulksms" , "0" , "1" );
        System.out.println( response );
    }
}
<%
    your_API_key = "80e7e7cbewirf5cdedj1ff52a8d225bf4b7b" 'put your API Key here
    your_user_name = "gbulksms-1"
    Recipient_phonenumber = "+2348087074329"
    message = "Hi Test sms recieved from gbulksms.com"
    originator  = "gbulksms"
    message_type  = "0"
    routeid  = "1"
    url = "https://www.gbulksms.com/api/sendsms?key=" + your_API_key + "&to=" + Recipient_phonenumber + "&message=" + message + "&from=" + originator + "&username=" + your_user_name+"&type=" + message_type+"&route=" + routeid

    set objSrvHTTP = Server.CreateObject("Msxml2.ServerXMLHTTP")
    objSrvHTTP.open "GET", url, False
    objSrvHTTP.send()
    Resp = objSrvHTTP.responseText

    Response.Write( Resp )
%>
using System;
using System.IO;
using System.Net;
using System.Text;
using System.Web;

namespace SendSMS {
    class Program {
        public static string SendSMS( string your_API_key, string your_user_name, string Recipient_phonenumber, string message, string originator, string message_type, string routeid ) {
            StringBuilder sb  = new StringBuilder();
            byte[] buf = new byte[ 1024 ];
            string url = "https://www.gbulksms.com/api/sendsms?key=" + your_API_key +
                "&to=" + Recipient_phonenumber + "&message=" +  message +
                "&from=" + originator + "&username=" + your_user_name+ "&type=" + message_type+ "&route=" + routeid;
            HttpWebRequest request = ( HttpWebRequest ) WebRequest.Create( url );
            HttpWebResponse response = ( HttpWebResponse ) request.GetResponse();
            Stream resStream = response.GetResponseStream();
            string tempString = null;
            int count = 0;
            do {
                count = resStream.Read( buf, 0, buf.Length );
                if ( count != 0 ) {
                    tempString = Encoding.ASCII.GetString( buf, 0, count );
                    sb.Append( tempString );
                }
            }
            while ( count > 0 );
            return sb.ToString();
        }
        static void Main( string[] args ) {
            string respXML = SendSMS( "80e7e7cbewirf5cdedj1ff52a8d225bf4b7b", "gbulksms-1", "+2348123456789", "Hi Test sms recieved from gbulksms.com", "gbulksms", "0", "1");
            Console.WriteLine( respXML );
       }
    }
}
/* * Send SMS C/C++ example need curllib download from http://curl.haxx.se/ */

#include <stdio.h>
#include <tchar.h>
#include <string.h>
#include <curl/curl.h>
#define URLSIZE 512

struct MemoryStruct {
        char *memory;
        size_t size;
};

/* Converts a hex character to its integer value */

char from_hex(char ch) {
        return isdigit(ch) ? ch - '0' : tolower(ch) - 'a' + 10;
}

/* Converts an integer value to its hex character*/

char to_hex(char code) {
        static char hex[] = "0123456789abcdef";
        return hex[code & 15];
}

/* Returns a url-encoded version of str */

char *url_encode(char *str) {
        char *pstr = str, *buf = (char *)malloc(strlen(str) * 3 + 1), *pbuf = buf;
        while (*pstr) {
                if (isalnum(*pstr) || *pstr == '-' || *pstr == '_' || *pstr == '.' || *pstr == '~')
                        *pbuf++ = *pstr;
                else if (*pstr == ' ')
                        *pbuf++ = '+';
                else
                        *pbuf++ = '%', *pbuf++ = to_hex(*pstr >> 4), *pbuf++ = to_hex(*pstr & 15);
                pstr++;
        }
        *pbuf = '\0';
        return buf;
}

/* CURL Callback write function */

static size_t WriteMemoryCallback(void *contents, size_t size, size_t nmemb, void *userp) {
        size_t realsize = size * nmemb;
        struct MemoryStruct *mem = (struct MemoryStruct *)userp;
        mem->memory = (char *)realloc(mem->memory, mem->size + realsize + 1);
        if (mem->memory == NULL) {
                /* out of memory! */
                printf("not enough memory (realloc returned NULL)\n");
                exit(EXIT_FAILURE);
        }
        memcpy(&(mem->memory[mem->size]), contents, realsize);
        mem->size += realsize;
        mem->memory[mem->size] = 0;
        return realsize;
}

/* Send SMS */

char * sendSMS(const char *your_API_key, const char *your_user_name, char *Recipient_phonenumber, char *message, char *originator, char *message_type, char *routeid) {
        static char url[URLSIZE] = "https://www.gbulksms.com/api/sendsms?key=";
        char *encoded;
        CURL *curl;
        CURLcode res;
        struct MemoryStruct chunk;
        chunk.memory = (char *)malloc(1);  /* will be grown as needed by the realloc above */
        chunk.size = 0;    /* no data at this point */
        curl = curl_easy_init();
        if(curl) {
                strcat_s(url, URLSIZE, your_API_key);
                strcat_s(url, URLSIZE, "&to=");
                strcat_s(url, URLSIZE, Recipient_phonenumber);
                strcat_s(url, URLSIZE, "&username=");
                strcat_s(url, URLSIZE, your_user_name);
                strcat_s(url, URLSIZE, "&from=");
                strcat_s(url, URLSIZE, originator);
                strcat_s(url, URLSIZE, "&message=");
                strcat_s(url, URLSIZE, message);
                strcat_s(url, URLSIZE, "&type=");
                strcat_s(url, URLSIZE, message_type);
                strcat_s(url, URLSIZE, "&route=");
                strcat_s(url, URLSIZE, routeid);
                curl_easy_setopt(curl, CURLOPT_URL, url);
                /* send all data to this function  */
                curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteMemoryCallback);
                /* we pass our 'chunk' struct to the callback function */
                curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&chunk);
                if((res = curl_easy_perform(curl)) != CURLE_OK) {
                        return NULL;
                }
                curl_easy_cleanup(curl);
        }
        return chunk.memory;
}

int main(void) {
        char *response;
        response = sendSMS("80e7e7cbewirf5cdedj1ff52a8d225bf4b7b", "gbulksms-1", "+2348123456789", "Hi Test sms recieved from gbulksms.com", "gbulksms", "0", "1");
        if(response != NULL) {
                printf(response);
                free(response);
        }
        getchar();
        return 0;
}
#include <iostream>
#include <string>
#using <System.Dll>
#using <System.Web.Dll>

using namespace std;
using namespace System;
using namespace System::Web;
using namespace System::Net;
using namespace System::IO;
using namespace System::Runtime::InteropServices;

ref class SMSSender
{

private:
        static String^ Key = "My API Key";

public:
        SMSSender()
        {}
        String^ SendSMS(String^ Recipient_phonenumber, String^ Message, String^ originator, String^ your_user_name, String^ your_API_key, String^ message_type, String^ routeid)
        {
                String^ URL = "https://www.gbulksms.com/api/sendsms?key=" + your_API_Key + "&message=" + Message + "&from=" + originator + "&to=" + Recipient_phonenumber "&username=" + your_user_name"&type=" + message_type"&route=" + routeid;
                WebRequest^ Handle = WebRequest::Create(URL);
                WebResponse^ HTTPResponse = Handle->GetResponse();
                StreamReader^ Stream = gcnew StreamReader(HTTPResponse->GetResponseStream());
                String^ Response = Stream->ReadToEnd()->Trim();
                HTTPResponse->Close();
                return Response;
        }
};

int main() {
        SMSSender^ test = gcnew SMSSender();
        String^ resp = test->SendSMS("+2348123456789", "Hi Test sms recieved from gbulksms.com", "gbulksms", "gbulksms-1", "80e7e7cbewirf5cdedj1ff52a8d225bf4b7b", "0", "1");
        Console::WriteLine(resp);
        return 0;
}
require 'net/http'
require 'uri'

def send_sms( your_API_key,your_user_name,Recipient_phonenumber, message, originator,message_type,routeid )
  requested_url = 'https://www.gbulksms.com/api/sendsms?key=' + your_API_key + 
"&username=" + your_user_name +"&to=" + Recipient_phonenumber + "&message=" +  message +
"&from=" + originator "&type=" + message_type"&route=" + routeid  
  url = URI.parse( requested_url )
  full_path = ( url.query.blank? ) ? url.path : "#{url.path}?#{url.query}"
  the_request = Net::HTTP::Get.new( full_path )
  the_response = Net::HTTP.start( url.host, url.port ) { |http|
    http.request( the_request )
  }
  raise "Response was not 200, response was #{the_response.code}" if the_response.code != "200"
  return the_response.bodyend
resp = send_sms( '80e7e7cbewirf5cdedj1ff52a8d225bf4b7b', 'gbulksms-1', '+2348123456789', 'Hi Test sms recieved from gbulksms.com', 'gbulksms', '0', '1' )

puts(resp)
Imports System.Web
Imports System.Net
Imports System.Text
Imports System.IO
Module Module1

	Public Function SendSMS( ByVal your_API_key As String, ByVal your_user_name As String, 
 ByVal Recipient_phonenumber As String, ByVal message As String, ByVal originator As String, ByVal message_type As String, ByVal route As String )
		Dim request As HttpWebRequest  
		Dim response As HttpWebResponse = Nothing  
		Dim reader As StreamReader  
		Dim url As String = "https://www.gbulksms.com/api/sendsms?key=" & your_API_key & "&username=" & your_user_name &"&to=" & Recipient_phonenumber & "&message=" &  message & "&from=" & originator& "&type=" & message_type& "&route=" & routeid 
		Try  
		    ' Create the web request  
		    request = DirectCast(WebRequest.Create(url), HttpWebRequest)  
		    ' Get response  
		    response = DirectCast(request.GetResponse(), HttpWebResponse)  
		    ' Get the response stream into a reader  
		    reader = New StreamReader(response.GetResponseStream())  
		    ' Return response
			SendSMS = reader.ReadToEnd()
		Finally  
		    If Not response Is Nothing Then 
				response.Close()  
				Console.WriteLine("Error connecting")
			End If
		End Try  
	End Function

    Sub Main()
        Dim result As String = SendSMS( "80e7e7cbewirf5cdedj1ff52a8d225bf4b7b", "gbulksms-1", "+2348123456789", "Hi Test sms recieved from gbulksms.com", "gbulksms" , "0", "1")
        Console.WriteLine( result )
        Console.Read()
    End Sub

End Module