Wednesday, January 20, 2010

Archive for the ‘SMS and MMS’ Category:

a simple Click-A-Tell SendSMS HTTP POST API library

Click-a-tell is a simple web service that allows you to integrate sms sending capability into your web application. Its simplicity and wide range of API available is very attractive to small to medium web application developers. Among the API supported by Clickatell are :

  • HTTP POST
  • HTTP GET
  • FTP API
  • SOAP
  • EMAIL-to-SMS
  • COM Object

Clickatell website offers examples of how to use their API in several programming language including but not limited to : VB.net, PHP, ASP, ASP.NET,PERL, Python, Coldfusion, etc.

However I found that the example written for PHP is a little bit outdated and it uses the file() function to initiate HTTP GET request which is generally restricted on webservers as it pose a huge security risk. The other Clickatell class found through PHPClasses website are either too cumbersome for my project or supported other protocol than I intended to use.

As a result I wrote my own Clickatell SMS (clickatell_sendsms_0.5.zip) class specifically for my own use.

Here are a sample code using the SendSMS 0.5 class

PHP:
  1. require('SendSMS.php');
  2. $sendsms = new SendSMS("username","password","HTTP POST API key");
  3. /* if the login return 0, means that login failed, you cant send sms after this */
  4. if ( ($sendsms->login()) == 0 ) {
  5. die( "failed");
  6. }
  7. /*other wise, you can send sms using the simple send() call*/
  8. $sendsms->send("0132073011","testing send sms - camna? boleh dpt ? - mr hafiz");
  9. ?>

You can download the clickatell_sendsms_0.5.zip">SendSMS 0.5 PHP class from this website, note that the class is licensed under the terms of the GNU General Public License version 2, and the class is only meant to be use with Click-A-Tell HTTP POST API.

The class can also be use with the libcurlemu library whenever applicable.


Don’t SMS and Drive, it’s bad for your health


Post a Comment

Template by : kendhin x-template.blogspot.com by :