Send Free SMS - Web Service

July 17th, 2008

27/Sep/2008 - Important Update 3: The web service has been updated yet again. If you are using the script on your own server, then please download the zip file again. Extract this zip file in the same place where sendsms.php is currently located and you should be good to go.


02/Sep/2008 - Important Update 2: The web service has been updated. If you are using the script on your own server, then please download the zip file again. Extract this zip file in the same place where sendsms.php is currently located. The zip file now contains an extra file named “htmlparser.inc” (version 1.2) from PHP HTML Parser. It’s an awesome library to parse HTML using PHP.


Important Update: After this comment from cssk, the web service has been updated. If you are using the script on your own servers, please download it again from here and just replace the existing file. Others, who are just accessing the URL on my domain needn’t make any changes to their code.


Hi friends, if you are in India and if you are developing software prototypes which has to send SMS alerts to various Indian mobile numbers, you needn’t spend a lot to buy SMS credits at the various sites. Over the last weekend, I spent some time hacking up a quick SOAP based web service which you can consume in your programs.

Before we proceed further, here are a few things you have to do:

  1. Get an account at http://www.way2sms.com/. Its a free SMS service and has tons of advantages; including 92 characters per message (rest of the characters are ads) and unlimited number of messages per day.
  2. Now you can invoke the web service in two ways from my domain itself. Web service endpoints and other notes given below.
  3. You can get the PHP source code and set it up in your own server.

Invoking the Web Service:

  1. The web service end point is at http://www.aswinanand.com/sendsms.php?wsdl. More details on how to consume a web service using Visual Studio is available here. Feel free to try with other languages and IDEs and let me know.
  2. Instead of consuming the web service, you can invoke the URL directly with the four parameters. Parameters are:
    • uid = your way2sms user id
    • pwd = your way2sms password
    • phone = semicolon separated list of phone numbers
    • msg = actual text message
  3. An example URL format is http://www.aswinanand.com/sendsms.php?uid=__USER_ID__&pwd=__PWD__&phone=__NUMBER__&msg=__MSG__.

Setting up the web service in your hosting space:

  1. Grab the SMS web service source code from here. The source code is licensed under “Creative Commons Attribution-Noncommercial”. Make sure you agree to the license terms before downloading :-) and kindly link back here or digg it.
  2. Get the NuSoap library and upload it to your server. You may want to change line number 50 in our web service source code to point to the proper location of NuSoap on your server.
  3. Now as mentioned in the section above, you can now use the web service from your domain. Just replace “http://www.aswinanand.com/” with “http://www.your-domain.com/path/to/source/” and you should be good to go on your own :D

Improvements:

Of course, there are lots of improvements that can be made to this service. Way2SMS console gives you a list of all the messages that have been sent from your account so far. So, you could write another web method and expose it; which returns all the messages so far in the form of RSS feed, ATOM feed or JSON.

Any text after the 92nd character in the SMS is cut off. We could write a simple loop after line 36 to send multiple messages if the number of characters exceeds 92.

We should also be able to retrieve the list of contacts that are saved in Way2SMS as JSON feeds and reuse them to send messages instead of typing in mobile numbers directly.

I will update the script as and when time permits and update this space. Keep watching for more. This sort of web services can be developed for almost all SMS web sites. If you are developing a similar script for other SMS websites, let me know.

Some boring blah blahs:

  1. The code is not production grade. It was hacked quickly over a weekend. So use it at your own risk.
  2. You cannot hold me responsible for whatever problems that may occur for you in using this web service.

You could also do me a small favour by digging this post. Thanks!

85 Responses to “Send Free SMS - Web Service”

  1. muthu Says:

    hi,
    i got the wsdl which is published by u.but it shows error : import schema for namespace was not resolved”
    so i cant add this wsdl file to my webreference.
    is this have any solution?

  2. rahil Says:

    hi dost kaise ho

  3. Aswin Anand Says:

    Muthu, I’m unable to get the same error. I’m able to access the WSDL as easily. Do you have any other namespace with the same name?

  4. cssk Says:

    Hey good post but i am unable to send any sms
    i tried both the method of using ur web service in asp.net and directly running the link
    http://www.aswinanand.com/sendsms.php?uid=__USER_ID__&pwd=__PWD__&phone=__NUMBER__&msg=__MSG__.

    can u suggest me

  5. Aswin Anand Says:

    @cssk:
    I just noticed that the way2sms website has changed a bit. I’m making the code changes. The new updated web service will be up tonight.

    Thanks for the info.

  6. cssk Says:

    Thanks for the reply
    can u post some code of using the webservices in asp.net application that wood be very good.
    One more thing i am trying to use an other webservice
    http://www.webservicex.net/SendSMS.asmx?wsdl
    but little sucess
    is there any other web service which can be used

  7. cssk Says:

    Hi Aswin

    Is ur Webservice working?

    Still Trying to get …..

  8. Aswin Anand Says:

    @cssk:
    I have updated the web service now & it works properly for me. Please try it out and let me know.

    I have tried webservicex.net’s SMS web service. But since it didn’t work, I created this :)

    Thanks!

  9. cssk Says:

    Hi Ashwin It’s Working….
    Thank u

  10. vivin Says:

    hi muthu, i can use ur webservice but u told that unlimited msgs can be sent, no its no correct only limited (arround 60) msgs can be sent, so, u please check it again and try whether there is any other wsdl to send more no.of sms or v can send more from way2sms.
    Reply reqd urgently. tnx in advance.

  11. Aswin Anand Says:

    @vivin:
    You can send as many messages as way2sms.com allows. AFAIK, there are no limitations on how many messages you can send per day using the site.

  12. Balasubramanian Says:

    Hi aswin.

    I am using the URL http://www.aswinanand.com/sendsms.php?uid=__USER_ID__&pwd=__PWD__&phone=__NUMBER__&msg=__MSG__. which provided above to send SMS. I am receving the output status as ‘DONE’ but i am not receiving any messages. Is there any restrictions, will the message receive for only particular providers?.

    Kindly Reply.
    Regards
    Bala..

  13. Aswin Anand Says:

    Bala,

    Hope you have created an account at way2sms.com and replaced the following details in the mentioned URL:

    1. replace __USER_ID__ with your way2sms user id.
    2. replace __PWD__ with your way2sms password.
    3. replace __NUMBER__ with the number to which messages has to be sent.
    4. replace __MSG__ with the actual message to be sent.

    I tried with my user name and password and it works perfectly. Most of the time, you will get the SMS within a second or two after the “done” message displays.

  14. soneone Says:

    I went ahead and modified the freely available rss2html to lookup a gmail feed (via freemyfeed.com) and send a sms via your scripts.. this leads to alerts with a small snippet of the mail :)

    Thanks for your script.

  15. Aswin Anand Says:

    @someone:

    Hey, that’s a pretty cool use of this SMS API. Appreciate that! :D

  16. soneone Says:

    looks like they changed it again.. i cant seem to send messages using the script.

    Contact me for the mail alert script at the email id i’ve entered for this post

  17. Balasubramanian Says:

    Hi Aswin.

    Thanks For ur reply. On that day itself i checked again by creating new user in way2sms,its worked fine.But, Today the URL http://www.aswinanand.com/sendsms.php?uid=__USER_ID__&pwd=__PWD__&phone=__NUMBER__&msg=__MSG__is not working. Whether any updates is going on.

    Regards
    Bala..

  18. Aswin Anand Says:

    @Bala:
    Another user has emailed me saying that the script is not working today. I’m looking into it.

  19. Aswin Anand Says:

    @bala, @soneone:

    You can now send SMS through the given URL.

  20. santosh Says:

    Dear Anand

    I have added the webservice to my application
    I haven’t received any message
    It works even when i give wrong password

    Please help me

    Thanks
    Santosh

  21. Aswin Anand Says:

    Hi Santosh, which version of visual studio are you using? I just consumed the SOAP web service and it worked out just fine. The WSDL is available at http://www.aswinanand.com/sendsms.php?wsdl

  22. hi krishna Says:

    sms is not send by your website by using
    http://www.aswinanand.com/sendsms.php?uid=__USER_ID__&pwd=__PWD__&phone=__NUMBER__&msg=__MSG__is not working. Whether any updates is going on.

  23. Aswin Anand Says:

    Krishna, the URL is working very well. You need to make sure to have a way2sms user ID and password. Are you having that? Have you read the instructions carefully before invoking the URL?

  24. Vivin Says:

    Hi muthu,
    Thanks for ur reply. I consumed ur webservice using my Java Client program, its working fine. I made some improvements to my Java web application ie 1)Long Messaging Service(LMS) like SMS, which allows us to send a text message of any length. 2)Calendar Events or Remainder Service, which allows us to set some remainders or calender events like B’Days and other important occasions and when that event fires then respective SMS/LMS is sent to them. But muthu, in my LMS service i’m unable to send more no.of msgs ie, when split the long text msg into no.of short msgs if the number exceeds some 60 or 70(approx) then the response from ur webservice is “done” as usually but, the remaining msgs after that limit are not being sent and when i try to send any msg there after in Way2sms.com its saying “Policy Violation Error: Too many msgs sent in a short period of time, Plz try later”. So please u chekt it out or try to send more than 100 sms from ur webservice/url. Any how its a very good job from u. Is there any way to retrive msgs sent to us from our client programs ie either by using other wsdls or by any other means. By the way did u try any other webservices to send free sms, I tried many but none is working (at free of cost). If u tried any such which were working please let me know. Awaiting ur reply. Thank u once again.
    Regards
    Vivin.

  25. Vivin Says:

    Hi muthu, May I know ur details(like academic & professional) if u don’t mind

  26. Aswin Anand Says:

    @vivin:
    Hey vivin, thanks for visiting my blog. Btw, I’m not “muthu”. I’m Aswin :) & I’m an engineering graduate and working for a software firm in Chennai.

    The web service was quickly hacked over a weekend & hence, those validations/checks need to be put into place.

  27. Vivin Says:

    Hi aswin, thanks for ur reply. sorry for assuming u as Muthu, anyhow can u tell me are any other successful wsdl to send unlimited sms a day.

  28. Aswin Anand Says:

    Vivin, I don’t think such a web service ever exists because of obvious reasons (spamming etc.). May be you can use paid services like the ones at http://www.smscountry.com.

  29. Vivin Says:

    Thanks for ur reply Aswin. what are you working on now, I mean any further progress in hacking Way2sms.com or any work done in sending sms using webservices for free of cost etc.

  30. Aswin Anand Says:

    Vivin, I’m working on automating smslife.in now :)

  31. Vivin Says:

    Tnx for ur reply aswin. Is it your professional work or your personnel work? any how can u give me some detailed description on “Automation of smslife.in”. Thanks in advance.

  32. Vivin Says:

    thanks for making me to know and use voice remainder service in smslife.in its working beautifully and it will be really amazing if that voice sms facility is enhanced to sms,alerts etc

  33. Aswin Anand Says:

    Vivin, automating is pretty simple. Its just a set of CURL (http://php.net/curl) requests and tracking responses, and validating them. You can go through the source code for the way2sms web service, which uses a similar technique. You can get the source code at the top of this blog post.

  34. Aswin Anand Says:

    Doing this is just for fun :) so that I can use them on my sidebar without having to visit the site everytime.

  35. Vivin Says:

    Hi aswin, thanks for ur reply. I am java guy, so can you help in that way.

  36. Aswin Anand Says:

    Sure Vivin. What help do you require?

  37. Baluvasireddy Says:

    Hi aswin yesterday webservice is working properly and all of a sudden today its not working……… what happen to the webservice im flex developer an im doing it from flex application… please update if the webservice is updated

  38. Aswin Anand Says:

    Balu, the web service can be used with any development platform. Looks like way2sms.com has undergone some changes. Will check them & make an update to this blogpost in a day. Please stay tuned.

  39. Vivin Says:

    Hi aswin, I want to set the web service in my own server, so can you please upload the latest/updated source(sendsms) in Java coz I am a Java Web Component Developer.

  40. JP Says:

    Hi Aswin,
    I have used your wsdl to send sms from my .net application. Every thing works fine but am not receiving any message. any updates going on from your end?
    the service is accepting null/blank password
    (i.e) working without any password given.
    Can you suggest any possiblities of mistake that am making?

    Thanks
    Jp

  41. Aswin Anand Says:

    Vivin, first priority is to stabilize this PHP web service. Of course I’m having plans to write a small library for .NET and Java too. Is it possible for you to maintain the Java library? Please let me know :) I would love that.

    JP, way2sms have some minor changes to the way the website sends SMS. I’m examining those changes & incorporating them. The changes will be released tonight. Regarding the empty password thing, I haven’t done much validation in the PHP side, mainly because I needed to get this out first. It will be taken care of in the next release after tonight’s release. Hope that’s fine.

  42. Jp Says:

    Aswin,
    Thanks for your response. Waiting for your Release.

    Thanks again,
    Jp

  43. Vivin Says:

    Hi aswin, I really love to maintain that webservice in my own server/machine. So, plz let me know how to maintain the Java library in my machine(is it by putting the path of the java class files in the classpath coz I am not sure abt it). Anyhow please let me know in detail.And when r u going to release ur new updated webservice, awaiting ur java lib release also. Thanks aswin.

  44. Aswin Anand Says:

    @JP, Vivin: The web service is back. You can send SMS now. I will be looking into the validations in the coming week.

    @Vivin: By maintenance, I meant about making future code changes and minor enhancements that may come along the way, like what I’m doing now to this PHP thing. Would you be able to maintain that? If so, kindly let me know. I will hack up a quick java program.

  45. Jp Says:

    Aswin,
    The code worked fine for me initially and its not working after sending few test messages.

    Is it possible to build .net code library?
    Can we do it?

    Thanks,
    Jp

  46. Vivin Says:

    Thanks Aswin,
    I can maintain the code, but I can do it if u provide me the code in Java, and really like to do some enhancements and of course I already did some like: Remainder service, Long message sending etc. Aswin, if u don’t mind can u tell me the process of hacking also.

  47. Aswin Anand Says:

    @JP: I tried sending a few messages by invoking the URLs and it worked well. Can you let me know after how many messages it stopped working? Yes, .NET code library can be built.

    @Vivin: Yes, the initial java code library can be built.

    For both the .NET and java library, allow me to use a week’s time. I will not be working on them because its a weekend :D So by next weekend, I can give a nice .NET & a java library.

  48. Vivin Says:

    ok aswin thank u. I will be awaiting ur java library. Mean while can u tell me the process of hacking also, I too will have try on that and I am very much interested also. or atleast let me know any good site(free) for learning hacking or give me some doc to learn how to do that. Thanks in advance.

  49. Joyce jose Says:

    Hi Aswin good work. plz do upload the .net library so that I can also look into it and hope to maintain it.

  50. Jp Says:

    Aswin,
    I have sent 6 messages. Even now i tried to send through my code it is not working. I tested from your URL and its working fine. But not from my code.
    Also there is no error thrown in the code. But the message is not received. I tried to put one For Loop in my code. Before that it was working fine. Is that could have cause any trouble?
    As Vivin Suggested can you through few lights on how to hack / what is the process involved am very much eager to learn few techniques and utilize it in a useful way. can you mail me jpxgen|at|gmail|dot|com

    Thanks in advance.

  51. Aswin Anand Says:

    Joyce, thanks a lot for the offer. I will be releasing the .NET and Java libraries on the coming weekend (within 4th & 5th Oct). You can take control of the source code from then onwards.

    Jp, there has been no “hacking” here. Please don’t get the wrong picture :) By hacking, I meant that a quick solution has been arrived at. Breaking into various systems means “cracking”, which we are *not* doing here.

    As far as how the code is implmented, there is one function named “sendSMSToMany”. It accepts 4 parameters. They are the user id, password, phone number and message. This function then sends a few HTTP requests to the way2sms server for logging in and sending the messages. Please go through the PHP code and let me know your doubts. I will be very glad to answer them. The code is well commented.

  52. Jp Says:

    Aswin,
    Sorry for the word Hacking. In spite of curiosity i have used that term. I will look into the PHP code. But i don’t have any idea about PHP :-( Anyway let me give a try.

  53. Joyce Jose Says:

    Yeah sure aswin I will look into it… but as JP says I am not able to send msg using ur webservice.

  54. Aswin Anand Says:

    JP, that’s the spirit :D Get back to me if you have doubts after looking at the code.

    Joyce, I just now accessed the URL and I’m able to send messages perfectly. Can you let me know how you tried to access?

  55. Joyce Jose Says:

    Aswin I have tried again now it is workin… thnks

  56. soneone Says:

    Stopped again

  57. Vivin Says:

    Hi aswin, the webservice is not working now, I think it was not working from 3 days. Are any changes are going on?

  58. Aswin Anand Says:

    @Vivin, @someone: Looks the way2sms website is down. I’m unable to access the website itself. Lets try again at the end of the day.

  59. Joyce jose Says:

    Hi Aswin has the url changed I see wwwg instead of http://www.

  60. tanik Says:

    hi,
    i tried to send more than one number 92xxxxxxxx,92xxxxxxxx from send.php from using http://www.aswinanand.com/sendsms.php but the response is done invalin number and messeage does not delivered. script is is not accepting mobilenumber as uid.plz tell me how to send to more than one numbers.

  61. Aswin Anand Says:

    @Tanik: Please read the blog post carefully again. ‘uid’ is the user id you created at way2sms.com. To send the same SMS to multiple numbers, you have to separate 2 or more numbers with semicolon (’;').

    @Joyce: It looks like way2sms redirects its users to one of their servers dynamically after login. That doesn’t affect us though.

  62. Abu Says:

    You can send SMS free to Cell Phones in Argentina:
    Radio Sabalera SMS
    Tested and works!

  63. Vivin Says:

    hi aswin, how r u? U told to release the Java version of the web service and also asked me to maintain the code in my own system, but what happened. I think u are busy with other works. So may i know how much time will to take for u to release it in Java version.

  64. Aswin Anand Says:

    Sorry Vivin, last week was a bit tight at work. I’m thinking of doing it this weekend. Hope that’s fine.

  65. Vivin Says:

    Thank you aswin, take ur own time b’coz u r alone taking all the pain of doing a good job for us. Thanks a lot.

  66. Vivin Says:

    Aswin, when i try to send sms using the webservice by providing my mobile no. as userid, its saying invalid login but when i give my userid(mailid) instead of mobile no. its accepting and am able to send sms. I think u have made some validations (like login validations) and may I please know what all the validations or preconditions u made for the webservice.

  67. Jp Says:

    Ashwin, What about the .net version? can you let me know when it will be released? so that we can maintain it.

    Jp

  68. Aswin Anand Says:

    JP, .net library is definitely in the cards. I’m on it this weekend after barcamp. Its on the way.

    Vivin, I just added login validation and phone number validation. If the user enters invalid user id or invalid password, it will be clearly shown.

  69. Waves » Blog Archive » Barcamp Chennai 2 - Interesting! Says:

    [...] control system which was developed by Linus Torvalds. I recently signed up at GitHub to host the SMS Web Service program & this session was really very helpful in getting me started. Next session was intro to Ruby on [...]

  70. Harish Says:

    Hi Aswin,

    i am developing a free sms portal using jsp.

    but i am not getting please help me

    send some javacodes related to free sms technology

    regards,
    Harish

  71. Muthu Says:

    hi,
    I tried to login using the url,
    http://www.aswinanand.com/sendsms.php?uid=__USER_ID__&
    pwd=__PWD__&phone=__NUMBER__&msg=__MSG__
    with my way2sms user id and pass which is working in the
    way2sms website.. but i got “invalid login ” i need help in getting the web service worked.plz reply
    Thanks,
    Muthucheliyan

  72. Aswin Anand Says:

    @Muthu: I tried just now with my login ID and password. SMS is being sent properly.

  73. Om Says:

    Hi,does it work in Bangladesh?

    Thanks
    Om

  74. Aswin Anand Says:

    Hello Om, as of now, this works only in India because way2sms supports India only.

  75. safal Says:

    HI,
    can i use you weservices
    and http://www.aswinanand.com/sendsms.php?uid=__USER_ID__&
    pwd=__PWD__&phone=__NUMBER__&msg=__MSG__
    and i copy the above URL and paste it in IE(intenet explore) but it didn’t worked out

  76. safal Says:

    HI,
    can i use you weservices
    and http://www.aswinanand.com/sendsms.php?uid=__USER_ID__&
    pwd=__PWD__&phone=__NUMBER__&msg=__MSG__
    and i copy the above URL and paste it in IE(intenet explore) but it didn’t worked out
    one more thing i forget to tell, after pasting the url
    in the internet explorer i am getting a message it is done, but the message was not recieved by my mobile which was entered in the url

  77. Suny Sharma Says:

    Thanks,
    It is easily integrated in asp.net application

  78. vivin Says:

    what else Mr.Aswin?

  79. vivin Says:

    any progress in sms web service?

  80. vivin Says:

    btw u r working on?

  81. Sharan Says:

    Hey Aswin,

    I downloaded the file that you have posted on your site and uploaded them to my web server including the .inc file (html parser) as well as the php. I even downloaded the nusoap files and added them to the server. The service works when I send a message and everything, but there is one small problem - it seems to add some slashes (’\') wherever I use single quotes in my code. And this happens only when I use the service from my server, but if I send the same exact message from your server, I don’t get that error.

    As I am a complete newbie when it comes to PHP, any help you can provide me to solve this problem would be greatly appreciated.

    Thanks.

    Sharan

  82. Aswin Anand Says:

    Sharan, looks like your single quotes are being escaped. To prevent escaping, you have to URL-encode them, which is what we are doing anyway.

  83. vivin Says:

    hi aswin, how r u? can u upload the java version of the webservice so that i can maintain both the web service and the my java client program on my machine. Thanks in advance. Awaiting ur code..

  84. vivin Says:

    hi aswin, Happy new year in advance. how r u? can u upload the java version of the webservice so that i can maintain both the web service and the my java client program on my machine. Thanks in advance.

  85. Aswin Anand Says:

    Hello Vivin, wish you the very same. The java library is on its way with the new year. I have just completed it. Will test it once and release it tomorrow.

Leave a Reply