Ok so today i am going to show you how to send a text message using clicktells api system.

First things first setup a clicktell account. You can do this here Clicktells Central Developers API Solution

Make sure that you select the correct country the you are based and wish to send texts from else it won’t work. I have selected the UK.

Activate you account from throguh the email sent by clicktell.

Login and then you will be asked to send an activaton code to the number that you provided when setting up your account.

It will be in a similar format to this “5b08909d”.

Ok great now you should be in central home and have an option to buy sms credits etc.

In the bottom left column their should be an option to Click here to create a connection (API ID)

I selected HTTP API as this is the option we will be using but i maight cover so others.

It will now show you your API ID “3274000”.

So it generates the following code.

password=<Clickatell Account Password>
to=<Mobile Number(s)> (comma separated)
text=<SMS Message>

And it also gives you an example string.


Ok now for and example just to check that everything is up and running copy the example string and paste into a new browser window and run.

Ok you should get the following errors
ERR: 001, Authentication failed

Ok this is fine and easy to solve if you look at the string you will see that the password varibale is set to PASSWORD.


Ok just enter the password that you set your account up with and run again and you should now recieve a text message.

Ok great no lets setup a simple form and then intergrate clicktells system.

Navigate to this page and grab some dummy code Clicktell Script.

Here is the script.

$user = "user";
$password = "password";
$api_id = "xxxx";
$baseurl ="http://api.clickatell.com";
$text = urlencode("This is an example message");
$to = "0123456789";
// auth call
$url = "$baseurl/http/auth?user=$user&password=$password&api_id=$api_id";
// do auth call
$ret = file($url);
// split our response. return string is on first line of the data returned
$sess = split(":",$ret[0]);
if ($sess[0] == "OK") {
$sess_id = trim($sess[1]); // remove any whitespace
$url = "$baseurl/http/sendmsg?session_id=$sess_id&to=$to&text=$text";
// do sendmsg call
$ret = file($url);
$send = split(":",$ret[0]);
if ($send[0] == "ID")
echo "success
message ID: ". $send[1];
echo "send message failed";
} else {
echo "Authentication failure: ". $ret[0];

You can test the example here.

Leave a Reply

Your email address will not be published. Required fields are marked *