Miscellaneous
  Home arrow Miscellaneous arrow Page 4 - Sending SMS Thru HTTP
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  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Download TestComplete 
Forums Sitemap 
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: 4 stars4 stars4 stars4 stars4 stars / 46
    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

  • 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


    Sending SMS Thru HTTP - Sending the request with CURL


    (Page 4 of 6 )

    Previously we saw that the request could be executed by pasting it into the browser window. But what we really want is for this to take place behind the scenes. The following code does exactly that using CURL.

    CURL is a very impressive library that allows you to connect and communicate to many different types of servers with many different types of protocols. You can find more info in the PHP Manual.

    This code opens up a connection with the gateway, sends the SMS message(s) and collects their message IDs which are presented within the response header.

    <?php
    $url 
    "http://www.tm4b.com/client/api/send.php"//this is the url of the gateway's interface
    $ch curl_init//initialize curl handle 
    curl_setopt($chCURLOPT_URL$url); //set the url
    curl_setopt($chCURLOPT_RETURNTRANSFER,1); //return as a variable 
    curl_setopt($chCURLOPT_POST1); //set POST method 
    curl_setopt($chCURLOPT_POSTFIELDS$request); //set the POST variables
    $response curl_exec($ch); //run the whole process and return the response
    curl_close($ch); //close the curl handle
    //print $response; //show the result onscreen for debugging
    ?>

    First, we initialize a new CURL session. Then we set our desired options; this includes setting CURLOPT_POST because TM4B's SMS API requires us to send multiple messages using POST. Finally we execute the call and then close the handle.

    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....
       · Hi,I have found another solution at http://www.ozekisms.com, that is just us...
       · Thanks Friend For Your Code Of Sending Sms through server. i think its...
     

    MISCELLANEOUS ARTICLES

    - Using PHP to Stream MP3 Files and Prevent Il...
    - 10 Must Have Firefox Improvements
    - All About OpenOffice 3.0
    - Shell Script Writing
    - Loops in the UNIX Shell
    - The Test in the UNIX Shell
    - Data Streams and the UNIX Shell
    - Control Mechanisms of the UNIX Shell
    - Variables Within the UNIX Shell
    - The Shell and UNIX
    - In Detail: UNIX File Systems
    - Rights Management in UNIX
    - UNIX File Systems
    - The Terminal in UNIX
    - Operating Systems and UNIX





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
    Stay green...Green IT