SMS php script (finally) working

Discussion in 'General' started by henkoegema, Aug 16, 2007.

  1. henkoegema

    Joined:
    Jul 12, 2007
    Messages:
    37
    Likes Received:
    0
    Finally some good news with php script in Elastix :lol:

    The sms php script is working! :) (nearly)
    Only the variabele ${TIMESTAMP} doesn't work. (which I reported earlier)


    [macro-send_sms_message]
    exten => s,1,NoOP(${ARG1})
    exten => s,n,System(/usr/bin/curl -sk "https://192.168.1.100:8888/sms/sms.php?number=${ARG1}&msg=At%20${ARG3}%20${ARG2}%20called.")

    exten => 3001,1,Wait(1)
    exten => 3001,n,Macro(send_sms_message,+32476378xxx,${CALLERID(num)},${TIMESTAMP})
    exten => 3001,n,Playback(vm-goodbye)
    exten => 3001,n,Hangup()


    This is the php script:
    =======================
    <?php

    function encryptString($string)
    {
    for($i=0; $i < strlen($string); $i++)
    {
    if(is_numeric($string[$i]))
    {
    if($string[$i] < "5")
    $string[$i] = $string[$i] + 5;
    else
    $string[$i] = $string[$i] - 5;
    }
    }
    return str_rot13($string);
    }

    // Set username and password
    $username = encryptString('henkoegema');
    $password = encryptString('xxxx');

    $URL = ('https://myaccount.voipbuster.com/clx/index.php?part=plogin&username=' . $username . '&password=' . $password);

    // Get number and message
    $number =($_GET['number']);
    $msg =($_GET['msg']);

    // INIT CURL
    $ch = curl_init();

    // SET URL FOR THE POST FORM LOGIN
    curl_setopt($ch, CURLOPT_URL, $URL);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);

    // SET POST PARAMETERS : FORM VALUES FOR EACH FIELD

    // IMITATE CLASSIC BROWSER'S BEHAVIOUR : HANDLE COOKIES
    curl_setopt ($ch, CURLOPT_COOKIEJAR, '/tmp/cookie.txt');

    # Setting CURLOPT_RETURNTRANSFER variable to 1 will force cURL
    # not to print out the results of its query.
    # Instead, it will return the results as a string return value
    # from curl_exec() instead of the usual true/false.
    curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);

    // EXECUTE 1st REQUEST (FORM LOGIN)
    $store = curl_exec ($ch);

    // SET Message
    curl_setopt($ch, CURLOPT_URL, 'https://myaccount.voipbuster.com/clx/websms.php');

    // ENABLE HTTP POST
    curl_setopt ($ch, CURLOPT_POST, 1);


    // SET POST PARAMETERS : FORM VALUES FOR EACH FIELD
    curl_setopt ($ch, CURLOPT_POSTFIELDS, 'message=' . $msg . '&bnrphonenumber=' . $number . '&submit=Send&action=send');

    // EXECUTE 2nd REQUEST (Send Message)
    $content = curl_exec ($ch);

    // CLOSE CURL
    curl_close ($ch);

    //debug
    //print $content;
    ?>
     
  2. lek

    lek Guest

    Great work!!

    By the way. Do you think voipbuster charge for its services in a near future?
     
  3. henkoegema

    Joined:
    Jul 12, 2007
    Messages:
    37
    Likes Received:
    0
    I has been free, but now they charge 1 c/min. (inside Belgium)<br><br>Post edited by: henkoegema, at: 2007/08/16 20:16
     

Share This Page