Miscellaneous
  Home arrow Miscellaneous arrow Page 33 - Sending SMS Thru HTTP
IBM developerWorks
Codewalker Forums 
  Tutorials  
Database Articles  
Miscellaneous  
Navigation Usability  
PEAR Articles  
Programming Basics  
Server Administration  
XML Tutorials  
  Reviews  
Database Book Reviews  
Linux Book Reviews  
Miscellaneous Reviews  
PHP Book Reviews  
PHP Software Reviews  
Server Admin Reviews  
SQL Tool Reviews  
  Code Gallery  
Content Management Code  
Contest Code  
Counters Code  
Database Code  
Date Time Code  
Discussion Board Code  
Email Code  
File Manipulation Code  
GUI Code  
Link Farm Code  
Miscellaneous Code  
Search Code  
Site Navigation Code  
User Management Code  
Forums Sitemap 
Dedicated Servers  
Download TestComplete 
IBM® developerWorks
Weekly Newsletter 
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
MISCELLANEOUS

Sending SMS Thru HTTP
By: Codewalkers
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 35
    2005-05-11

    Table of Contents:
  • Sending SMS Thru HTTP
  • Understanding the Requirements of the Gateway
  • Prepare the Request
  • Sending the request with CURL
  • Sending the Request with Sockets
  • Conclusion
  • Introduction
  • Understanding the Requirements of the Gateway
  • Prepare the Request
  • Sending the request with CURL
  • Sending the Request with Sockets
  • Conclusion
  • Introduction
  • Understanding the Requirements of the Gateway
  • Prepare the Request
  • Sending the request with CURL
  • Sending the Request with Sockets
  • Conclusion
  • Introduction
  • Understanding the Requirements of the Gateway
  • Prepare the Request
  • Sending the request with CURL
  • Sending the Request with Sockets
  • Conclusion
  • Introduction
  • Understanding the Requirements of the Gateway
  • Prepare the Request
  • Sending the request with CURL
  • Sending the Request with Sockets
  • Conclusion
  • Introduction
  • Understanding the Requirements of the Gateway
  • Prepare the Request
  • Sending the request with CURL
  • Sending the Request with Sockets
  • Conclusion

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    Sending SMS Thru HTTP - Prepare the Request


    (Page 33 of 36 )

    Now the actual message-delivery process is handled by the gateway. All they want us to do is pass them the details of the message(s) in the form of an HTTP request, similar to this one:

    http://www.tm4b.com/client/api/send.php?username=abcdef&password=12345&msg=This+is+sample+message.&to=447768254545%7C447956219273%7C447771514662&from=MyCompany&route=frst&sim=yes

    You can test the above example (which uses GET) by pasting it into your browser's address bar. You should get a response saying that the username is invalid, which is normal because this is just to demonstrate.

    The first step is to save our data as variables and then convert them into a URL request. There are different ways of doing this, but this is a very innovative and useful way:

    <?php
    $request 
    ""//initialize the request variable
    $param["username"] = "abcdef"//this is the username of our TM4B account
    $param["password"] = "12345"//this is the password of our TM4B account
    $param["msg"] = "This is sample message."//this is the message that we want to send
    $param["to"] = "447768254545|447956219273|447771514662"//these are the recipients of the message
    $param["from"] = "MyCompany";//this is our sender 
    $param["route"] = "frst";//we want to send the message via first class
    $param["sim"] = "yes";//we are only simulating a broadcast

    foreach($param as $key=&gt;$val//traverse through each member of the param array

      
    $request.= $key."=".urlencode($val); //we have to urlencode the values
      
    $request.= "&amp;"//append the ampersand (&amp;) sign after each paramter/value pair
    }
    $request substr($request0strlen($request)-1); //remove the final ampersand sign from the request
    ?>

    We assign our credentials and routing information in the $param array. You'll notice that multiple recipients can be defined by separating them with the pipe-character. Each parameter value needs to be urlencoded and multiple key/value pairs are separated by ampersands. A final ampersand probably would not cause any problems but substr is still used to produce a tidy request.

    The script will produce the following request that can be sent to the SMS gateway:username=abcdef&password=12345&msg=This+is+sample+message.&to=447768254545%7C447956219273%7C447771514662&from=MyCompany&route=frst&sim=yes

    More Miscellaneous Articles
    More By Codewalkers


       · You can use the http_build_query() function instead of using the foreach loop by...
       · When sending request using sockets, you set the $method variable to...
       · With regards to http_build_query, sounds interesting! I'd like to give it a go when...
       · Thanks for the comment.Basically, you can replace &quot;POST&quot; with...
       · If I want to set up a system that is to send texts to individuals in different...
       · You'll find that all SMS Gateways require you to pass them the telephone numbers of...
       · To avoid encoded chunks, use HTTP 1.0.
       · Have you tried it? Does it work?
       · Chunked transfer-encoding was introduced in HTTP 1.1. The only mention of...
       · thank u for ur good work !!!
       · for Philippines, China, Japan, Hong Kong, Indonesia, Thailand, Singapore and...
       · salam! ki&amp;#351;i iki g&uuml;nd&uuml;r senin mailini...
       · salam! ki&amp;#351;i iki g&uuml;nd&uuml;r senin mailini...
       · Hy.... can anyone help me with this script. I can't help myself. Can anyone send me...
       · 
       · gjmbnmbbbnm
       · With the new api you need to change a few params..you need add...
       · sir first time try to this option isnot success but mail server option is vary...
       · I read through the tutorial, and I am a little confused on how the pieces of code...
       · here is another very simple worldwide SMS gateway....
     

    MISCELLANEOUS ARTICLES

    - Stopping CSRF Attacks in Your PHP Applicatio...
    - Quick and Dirty AJAX Tutorial
    - Flickr Puzzle Mashup
    - The PAVISE of Security
    - Creating a CAPTCHA with PHP
    - Sending SMS Thru HTTP
    - The Postal Fix - Part 2
    - Adding Mail with Exim
    - The Postal Fix - Part 1
    - Create Your Own Custom API
    - Adding Drop Shadows with PHP
    - Writing a Basic Authentication System in PHP
    - Overlapping Images with GD
    - Using Sockets in PHP
    - Dynamic CSS with PHP






    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway