17th Dec ’10 :

Now here’s the deal. 160by2,way2sms and freesms8 offer free SMS and earn money through the ads on their website. By using this PHP script, we are bypassing their website illegally as their ad never gets shown. I hope you will keep this in mind when you use this script. If you want to send free SMS legally, then head over to http://freesmsapi.com and create an account. They are offering an excellent service totally free of cost.
Also the developers at way2sms and freesms8 keep changing their url’s and security methods to prevent such scripts from working (160by2.com guys are cool about this). And as this PHP code published here can be viewed publicly, their jobs become easy. So I will not be able to continue development of the scripts because as soon as I publish the code here, way2sms/freesms8 change their code to break my code.
So there should be a way to restrict access to the PHP code published here so that the code reaches appropriate hands only. Maybe a password protected SVN or forums based on reputation points, I dont know..
Post in your opinions about this as a comment and lets see whether we can work it out together.

Update as of 5th Oct ’10 : Bulk SMS services restored !!

Update as of 24th Sep ’10 : Govt has banned bulk sms temporarily. So all the bulk sms providers have stopped their services. More info. This script will not work till Sep 29th. In the meantime, I will upload the next version of the script which can check internet connectivity, login errors and other responses sent by the gateway. I will also be adding support for freesmsapi.com and freesms8.com gateways.

Update as of 10th Sep ’10: The code has been updated to accomodate a small change in the way2sms website.

Update as of 15th Aug ’10 : The code has been updated to work on all 160by2 and way2sms accounts and also will fetch any error codes being generated by these gateways. If you encounter any bugs, drop in a comment.

This is a PHP script I wrote a while back to automate the sending of SMS/text message using 160by2.com/way2sms.com account.

You can use this PHP API script to send free sms India, Kuwait, Singapore, UAE, Phillipines, Malaysia etc. Very useful if you are combining this with the registration page of your website to verify the users mobile number similar to verification of their email address.

Some possible real world applications of this script are :
1. Email to SMS.
2. Birthday alerts/Daily joke/thought for the day/news SMS
3. Gtalk/XMPP to SMS

Pre-requisites to use this script :
1.You need a hosting server with PHP5 and cURL extension enabled. The server should be able to open socket connections to other servers.
2.a valid,verified 160by2.com account or way2sms.com account (Create an account for free on one of these gateways and send a test SMS through their UI first.)

Example Usage (Also included in example.php):

include_once “class.curl.php”;
include_once “class.sms.php”;

$smsapp=new sms();
$smsapp->setGateway(‘way2sms’); // you can set gateway to be 160by2 to use your 160by2 account;
// way2sms code has been tested on different accounts to be stable.

echo “Logging in … “;
$smsapp->login(‘username for way2sms’,'password’);

echo “Sending SMS … “;
$result=$smsapp->send(’10 digit mobile number’,'Your text message’);

echo “Message sent”;
echo “Error encountered : “.$smsapp->getLastError();

Limitations :
1. 160by2.com offers a character limit of around 145 for each message. Way2sms offers a character limit of 140 characters per message. Please see that the character limit is honored.
2. also a limit of 50 messages per day per account and 10 messages per recepient phone number holds good for 160by2.

(27388 hits)


Click here for a simple demo application to send free SMS using this API

I had also written a script using this class to send an sms alert to notify as soon as the booking for an upcoming movie opens up on bookmyshow.com, if someones interested in using this bookmyshow script, drop in a comment.


Supports 160by2, freesmsapi, freesms8. Does not support way2sms as of now.

To send free SMS all over the world using your iPhone/iPod touch, use Textoo Pro app. It is currently the best iphone app to send free unlimited text messages easily.

(13602 hits)
PHP class to send SMS using free SMS gateways, 10.0 out of 10 based on 1 rating

Incoming search terms: