<?
//Author and Revised by: MIchael Norman Rondero
define(USR,'your username');
define(PWD,'your password');
define(APIID,'your clickatell api id');
define(SID,'Sender ID');
class CLICKATELLSMS {
function CLICKATELLSMS()
{
$this->_sendURL = "http://api.clickatell.com/http/sendmsg?api_id=%s&user=%s&password=%s&from=%s&text=%s&to=%s&callback=0&concat=1";
$this->sending_method = "fopen";
//Note: sending method can be change to curl function but
//you need to came up about curl function
}
function _sendSMS($text=NULL,$to=NULL)
{
$text = stripslashes($text);
$text = str_replace("\r", "", $text);
if(strlen($text) > 161) {
die("message too long");
}
if (empty ($to)) {
die ("You not specify destination address (TO)!");
}
$cleanup_chr = array ("+", " ", "(", ")", "\r", "\n", "\r\n");
$to = str_replace($cleanup_chr, "", $to);
$comm = sprintf ($this->_sendURL,
APIID,
USR,
PWD,
SID,
rawurlencode($text),
rawurlencode($to));
return $this->_parse_send
($this->_execgw($comm));
}
function _execgw($command)
{
if ($this->sending_method == "fopen")
return $this->_fopen($command);
die ("Unsupported sending method!");
}
function _fopen($command)
{
$result = '';
$handler = @fopen ($command, 'r');
if ($handler) {
while ($line = @fgets($handler,1024)) {
$result .= $line;
}
fclose ($handler);
return $result;
}
else
{
die ("Please use Latest Version of PHP");
}
}
function _parse_send ($result) {
return $result;
}
}
?>