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
|
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
|
Optional |
type |
Type of message to be sent
|
Optional |
reference |
A unique reference number to identify your transaction for your records | Optional |
dlr |
To request a delivery report
|
Optional |
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:
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.
A JSON formatted object containing the following:
https://sms.dtechghana.com/api/v1/send?to=233241234567&from=Devchild&content=Hello%2C+World&id=dro134uji&secret=2Uo3643h3mH4rw4R
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" }
<?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(); } } }