I have been receiving numerous emails on how to send SMS Messages using Clickatell’s HTTP API with a PHP script. I have therefore designed this tutorial to send a simple sms message using clickatell’s HTTP API.

This tutorial basically solves three things.

1. Send a simple sms message on clickatell’s sms gateway using HTTP
2. Retrieve the apimsgid of a message and stores it in a mysql table
3. Use the callback url to check the status of an sms message

Before you start, make sure the following have been done.

1. Register at Clickatell for your account.

2. Register for an HTTP API account at your clickatell control panel. Once you create and HTTP API account, you will be assigned the following. (username, password and api_id) wich you will insert in your script.

3. Whilst on the HTTP API control panel, assign the callback url. Eg. www.mysite.com/callback.php

Once all these are settle we will create our mysql table

Mysql Tables

CREATE TABLE `tbl_outbox` (
`messageid` bigint(10) NOT NULL auto_increment,
`sender` varchar(20) default NULL,
`recipient` varchar(20) default NULL,
`status` varchar(50) default ‘008′,
`apimsgid` varchar(50) default NULL,
`charge` decimal(5,2) default ‘0.00′,
`timesent` varchar(50) default NULL,
`message` tinytext,
`dated` varchar(30) default NULL,
PRIMARY KEY (`messageid`)
) TYPE=MyISAM;

Note:
//Sender: Stores the phone number of the sender
//Receipient : stores the number of the recipient
//Status: I use this to store the the status of the text message
//Apimsgid: this stores the apimsgid of the text message
//Timesent: this is the timestamp on of the message when its sent
//Message: stores the message you are sending
//Dated: its something I just use to show when I sent it from the site

Download Tutorial >>

Part 1 | Part 2 | Part 3 | Part 4 | Part 5 | Part 6 | Part 7