Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5

Thread: Send SMS code

  1. #1
    Regular Coder
    Join Date
    Sep 2007
    Location
    Grahamstown, South Africa
    Posts
    237
    Thanks
    6
    Thanked 17 Times in 17 Posts

    Send SMS code

    Hi there,

    I thought a lot of you guys might find this interesting, its an API to send SMS's from a browser etc. Just keep in mind that you have to set up an account with panaceamobile @ www.panaceamobile.com! But sending a sms with them is generally a whole lot cheaper anyway!

    Enjoy the API:
    PHP Code:
    <?php

    function send_message($username$password$from$to$message$track_delivery 0) {
        
    $url "http://api.panaceamobile.com/sendsms?1";
        
    $data = array(
            
    "to" => $to,
            
    "from" => $from
            
    "dlr-mask" => $track_delivery,
            
    "text" => $message,
            
    "username" => $username,
            
    "password" => $password
        
    );
            
        foreach(
    $data as $key => $val) {
            
    $data[$key] = urlencode($val);
        }



        
    $str $url;
        foreach(
    $data as $key => $val) {
            
    $str .= "&{$key}={$val}";
        }

        
    $ch curl_init();
        
    curl_setopt($chCURLOPT_URL$str);
        
    curl_setopt($chCURLOPT_HEADER0);
        
    curl_setopt($chCURLOPT_RETURNTRANSFER1);
        
    $res curl_exec($ch);

        if(
    $res !== FALSE) {
            if(
            (
    strpos($res"Accepted") === FALSE) &&
            (
    strpos($res"Queued") === FALSE) &&
            (
    strpos($res"Sent") === FALSE)
            )
            return 
    false;
            return 
    true;
        }
        return 
    false;
    }

    $to "44325321234";
    $from "4432532021";


    if(
    send_message("myusername""mypassword"$to$from"Hello Messaging!"1)) {
        echo 
    "Message Sent!";
    } else {
        echo 
    "Message Failed!";
    }


    ?>

  • #2
    Regular Coder
    Join Date
    Sep 2007
    Location
    Grahamstown, South Africa
    Posts
    237
    Thanks
    6
    Thanked 17 Times in 17 Posts
    Quite useful if you are implementing a solution with a client who needs SMS support! :-D

  • #3
    Banned
    Join Date
    Mar 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up

    Nice share i will try this an see how it works............

  • #4
    New to the CF scene
    Join Date
    Mar 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hmm this could be useful, thanks for sharing!

  • #5
    12k
    12k is offline
    New Coder
    Join Date
    Jan 2012
    Posts
    29
    Thanks
    0
    Thanked 6 Times in 6 Posts
    I always prefer just simply sending it using a smtp. Only downside is some phone carriers consider it as a data charge even though its a text message. Its free for you to send texts anyways


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •