Sign in to follow this  
Followers 0
anixon

SMS Gateway

8 posts in this topic

#1 ·  Posted (edited)

The following are some code examples from an organisation that provides an SMS Gateway. The simple question is can this functionality be adapted into an AutoIT Script and how would that be coded. Help is always appreciated.

VB Example:

<%    MsgBox(SendSMS("http://www.smsglobal.com/http-api.php", SmsGlobalData("USERNAME", _                                                                          "PASSWORD", _                                                                          "SENDER_ID", _                                                                          "DESTINATION", _                                                                          "TEXT: HELLO WORLD")))    Private Function SMSGlobalData(ByVal username As String, _                                   ByVal password As String, _                                   ByVal source As String, _                                   ByVal destination As String, _                                   ByVal text As String) As String                                           Dim postData As New System.Text.StringBuilder("action=sendsms")        postData.Append("&user=") : postData.Append(System.Web.HttpUtility.UrlEncode(username))        postData.Append("&password=") : postData.Append(System.Web.HttpUtility.UrlEncode(password))        postData.Append("&from=") : postData.Append(System.Web.HttpUtility.UrlEncode(source))        postData.Append("&to=") : postData.Append(System.Web.HttpUtility.UrlEncode(destination))        postData.Append("&text=") : postData.Append(System.Web.HttpUtility.UrlEncode(text))        Return postData.ToString()    End Function    Private Function SendSms(ByVal url As String, _                             ByVal postData As String) As String        Dim encoding As New System.Text.UTF8Encoding()        Dim data As Byte() = encoding.GetBytes(postData)        Dim smsRequest As HttpWebRequest = System.Net.WebRequest.Create(url)        smsRequest.Method = "POST"        smsRequest.ContentType = "application/x-www-form-urlencoded"        smsRequest.ContentLength = data.Length        Dim smsDataStream As System.IO.Stream        smsDataStream = smsRequest.GetRequestStream()        smsDataStream.Write(data, 0, data.Length)        smsDataStream.Close()        Dim smsResponse As System.Net.WebResponse = smsRequest.GetResponse()        Dim responseBuffer(smsResponse.ContentLength - 1) As Byte        smsResponse.GetResponseStream().Read(responseBuffer, 0, smsResponse.ContentLength - 1)        smsResponse.Close()        Return encoding.GetString(responseBuffer)    End Function%>


And a PHP Example


<?php 
    function sendSMS($content) { 
        $ch = curl_init('http://www.smsglobal.com.au/http-api.php'); 
        curl_setopt($ch, CURLOPT_POST, true); 
        curl_setopt($ch, CURLOPT_POSTFIELDS, $content); 
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
        $output = curl_exec ($ch); 
        curl_close ($ch); 
        return $output;     
    } 

    $username = 'USERNAME'; 
    $password = 'PASSWORD'; 
    $destination = 'PHONE NUMBER'; 
    $source    = 'FROM NAME'; 
    $text = 'SAMPLE TEXT'; 
         
    $content =  'action=sendsms'. 
                '&user='.rawurlencode($username). 
                '&password='.rawurlencode($password). 
                '&to='.rawurlencode($destination). 
                '&from='.rawurlencode($source). 
                '&text='.rawurlencode($text); 
     
    $smsglobal_response = sendSMS($content); 
     
    //Sample Response 
    //OK: 0; Sent queued message ID: 04b4a8d4a5a02176 SMSGlobalMsgID:6613115713715266  
     
    $explode_response = explode('SMSGlobalMsgID:', $smsglobal_response); 
     
    if(count($explode_response) == 2) { //Message Success 
        $smsglobal_message_id = $explode_response[1]; 
         
        //SMSGlobal Message ID 
        echo $smsglobal_message_id; 
    } else { //Message Failed 
        echo 'Message Failed'.'<br />'; 
         
        //SMSGlobal Response 
        echo $smsglobal_response;     
    } 
?>

Edited by anixon

Share this post


Link to post
Share on other sites



The VB code example can be viewed when expanded Ant..

Share this post


Link to post
Share on other sites

The VB code example can be viewed when expanded Ant..

Thanks for that but at first glace it looks like a email account gateway where my interest was establishing if you could use AutoIT to send SMS's using web page gateway service.

Ant..

Share this post


Link to post
Share on other sites

Suppose so, so what you really need to know is how to convert that VB to AutoIt3?

I am playing with the code that you directed to me at the end of the day the methodology is driven by price per SMS.

The code for my example has universal world wide SMS pricing at 0.10c per SMS down to 0.05c for volume. My service provider charges 0.25c per SMS for Aus delivery and better than double that for International.

I guess I am look for assistance as to how to change the code from VB to AutoIT 'skills that I do not have'

Ant..

Share this post


Link to post
Share on other sites

I wish I could help you , except I no nowt about VB, although it looks like it would be a lot simpler in autoit.

I can direct you toward trancexx winhttp udf, which you can find in example script section.

I say that because the VB code seems just to be creating a POST string.

Worth a look.


AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

I wish I could help you , except I no nowt about VB, although it looks like it would be a lot simpler in autoit.

I can direct you toward trancexx winhttp udf, which you can find in example script section.

I say that because the VB code seems just to be creating a POST string.

Worth a look.

I think you are right I going to subscribe to a test account and then send the string manually and see what I get then I can turn my mind to how to achieve that efficiently

Thanks for your help and guidance

Ant.. Posted Image

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0