I have been building a facebook sms app and needed to use Clickatell gateway to send sms using their http api, I have used their sample php script in the past, but for this app I’m using CodeIgniter a powerfull php object oriented framework and need to keep my code clean so I had to use Clickatell http API in a better way so I wrote this simple sms class (Download from Bitbucket).
Basic Usage:
require_once 'clickatell.php'; # initialize class $sms = new Clickatell(); # Prepare and send $sms->to = "002154584"; $sms->msg = "This is a text"; $sms->send();
in the example above I assume that you have added your clickatell username, password and api_id in the class file
if not then you would do something like this:
require_once 'clickatell.php'; # initialize class $sms = new Clickatell(); # set clickatell credentials $sms->username = "myuser"; $sms->password = "mypass"; $sms->api_id = "myapiid"; # Prepare and send $sms->to = "002154584"; $sms->msg = "This is a text"; $sms->send();
The class Send function will either return a message ID (if send succeed) or return false if failed.
if you are developing and want to debug then simply add this before using $sms->Send()
$sms->debug = true;
then the Send function will either return a message ID on success or return something like this:
Type: Error
Error Code: 135
Error Message: Authentication Failed
You can download Clickatell PHP Class from bitbucket
https://bitbucket.org/amaroks/clickatell_php/src
You can see the Facebook sms app I built here:
http://apps.facebook.com/sms_world/
Let me know if you have any questions!