HTTP (Quick Send) API

Overview

The HTTP API enables you send SMS quickly. To send SMS, simply call the following URL with the relevant parameters appended to the URL, as shown below:

https://sms.dtechghana.com/api/v1/send?to={To}&from={From}&content={Content}&id={Username}&secret={ApiKey}

 

HTTP Parameters

Below is a list of parameters when issuing a HTTP Request.

Parameter Description Presence
to
Recipient phone number
  • Must be a valid MSIDSN
  • Must be in the international telephone number format without the '+' symbol. e.g. 233241234567
Required
from
Sender ID (3-11 characters, alphanumeric)
Required
content The message to be sent. Must be URL encoded. Required
id Your SMS account username Required
secret Your SMS account API Key Required
time
To schedule the message to be sent sometime or date in the future
  • Format: YYYY-MM-DD HH:MM:SS or UNIX TIMESTAMP
  • Scheduled time must be at least 10 minutes ahead of current time in UTC
Optional
type
Type of message to be sent
  • 0 - Regular Text Message
  • 1 - Binary Message
  • 2 - Unicode Message
Optional
reference A unique reference number to identify your transaction for your records Optional
dlr
To request a delivery report
  • Type: Boolean
  • Possible values: yes or no
Optional

Request Response

Each time you send a request to the API, the API issues a response containing information related to your request. The API response generally includes the following:

Response Header:

Standard HTTP code indicating the success or otherwise of the request. A 200 status code indicates a successful request, whereas 4xx or 5xx indicate a failed request.

Response Body

A JSON formatted object containing the following:

  • "Status" - indicates the status of the API request. "00" indicates a successful request, while "01" indicates an unsuccessful request.
  • "Id" - internal (Gateway) message ID for the sent message
  • "Rate" - the SMS rate for the sent message.
  • "Reference" - the unique reference provided during the API call. Defaults to NULL if no reference was provided.
  • "MessageStatus" - indicates the current status of the message i.e. "Sent" or "Scheduled"
  • "Message" - error message associated with a failed request. This will only be provided if the request wasn't successful.

 

Examples

Example Request
https://sms.dtechghana.com/api/v1/send?to=233241234567&from=Devchild&content=Hello%2C+World&id=dro134uji&secret=2Uo3643h3mH4rw4R

 

Example Response
HTTP/1.1 200 OK
Date: Wed, 09 Mar 2016 22:54:53 GMT
Server: HTTP API Server
Content-Length: 102
Content-Type: application/json; charset=utf-8


{  
   "Status":"00",
   "Id":"3c5c0a28b89f38e58dbe334bcfb7bae4",
   "Rate":1,
   "Reference":null,
   "messageStatus":"Sent"
}
                    

 

Programming examples using the HTTP API:

 

<?php
// Sending a single message using Quick send API in PHP
                            
$baseurl = "https://sms.dtechghana.com/api/v1/send";
                            
$params = array("from"=>"John", "to"=>"233241234567", "content"=>"Hello Jane!", "id"=>"dro134uji", "secret"=>"2Uo3643h3mH4rw4R");
$params = "?" . http_build_query($params);
                            
$response = file_get_contents($baseurl.$params);

# Sending a single message using Quick send API in Python

import urllib2
import urllib

baseParams = {'to':'233241234567', 'from':'John', 'content':'Hello Jane!', 'id':'dro134uji', 'secret':'2Uo3643h3mH4rw4R'}

# Send an SMS with minimal parameters
urllib2.urlopen("https://sms.dtechghana.com/api/v1/send?%s" % urllib.urlencode(baseParams)).read()

# Sending a single message using Quick send API in Ruby

require 'net/http'

uri = URI('https://sms.dtechghana.com/api/v1/send')
params = { :id => 'dro134uji', :secret => '2Uo3643h3mH4rw4R', :to => '233241234567', :from => 'John', :content => 'Hello world' }
uri.query = URI.encode_www_form(params)

response = Net::HTTP.get_response(uri)

// Sending a single message using Java
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import javax.net.ssl.HttpsURLConnection;

public class CallApi {
	public static void main(String[] args) {
		try{
			String url = "https://sms.dtechghana.com/api/v1/send?";
			String params = "id=dro134uji&secret=2Uo3643h3mH4rw4R&to=233241234567&from=John&content=Hello world";
			
			URL obj = new URL(url+params);
			HttpsURLConnection connection = (HttpsURLConnection) obj.openConnection();
			int responseCode = connection.getResponseCode();
			BufferedReader in = new BufferedReader(
				new InputStreamReader(connection.getInputStream())
			);
			String inputLine;
			StringBuffer response = new StringBuffer();
			while ((inputLine = in.readLine()) != null) {
				response.append(inputLine);
			}
			in.close();
			
			//print result
			System.out.println(response.toString());			
		}
		catch(Exception e){
			e.printStackTrace();
		}
	}
}	

 

Next: REST API