Alpha Video Training
Results 1 to 5 of 5

Thread: http_post

  1. #1
    Member
    Real Name
    Walter
    Join Date
    Jun 2003
    Location
    South Africa
    Posts
    456

    Default http_post

    Hello All,

    I need help on the http_post function please. I am not sure if this is the correct function for the values I need to send as I am not too clued up with this one.
    Basically, I need to send values to their server in order for them to send out an sms or bulk sms'es
    In the example they wanted the following values:
    Type of post: single or bulk
    username
    password
    etc.

    They did send me an example of the values to be posted and mentioned I should use a http_post function for this:
    HTML Code:
    </form>
    </td></tr>
    <tr><td height="10"></td></tr>
    <td><tr>
    <form method="POST" action="http://www.smsportal.co.za/httppost3.aspx">
    <input type="hidden" name="Type" size="20" value="Bulk">
    <Table border=1>
    <tr><td colspan="2">Bulk SMS</td></tr>
    <tr><td>Username</td><td><input type="text" name="Username" size="20"></td></tr><!--You username -->
    <tr><td>Password</td><td><input type="text" name="Password" size="20"></td></tr><!--You Password -->
    <tr><td>Number</td><td><input type="text" name="Numbers" size="20"></td></tr><!--Numbers in a comma seperated string eg: 0832297941,0832297911-->
    <tr><td>Message</td><td><input type="text" name="Message" size="20"></td></tr><!--Your message no longer than 160 chars -->
    <tr><td>SendDate</td><td><input type="text" name="SendDate" size="20" value="2/Nov/2005"></td></tr><!--date in the format dd/mmm/yyyy -->
    <tr><td>SendTime</td><td><input type="text" name="SendTime" size="20" value="21:00"></td></tr><!--24 hour time format HH:mm -->
    <tr><td></td><td> <input type="submit" value="Submit" name="B1"></td></tr>
    <!--It will return the a "true" or "false" and then a description eg: "False, your username and password do not match!" or "True, Successfully sent"
    Any asistance with this will be much appreciated.
    Walter
    Last edited by AaronBBrown; 10-24-2006 at 01:42 PM.

  2. #2
    "Certified" Alphaholic
    Real Name
    Finian Lennon
    Join Date
    Apr 2000
    Location
    Atlanta, GA
    Posts
    1,805

    Default Re: http_post

    I haven't done this yet myself - but I will have to soon using http_post2, so I'm interested in this topic.

    Result as P = HTTP_POST( URL as C [, Body as C [, Cookie as C [, Port as N [, Timeout as N, [ Show_Before_Send as L [, Validate_SSL_Certificate as L ]]]]]] )

    It looks like they have sent you a sample of what the body of the submission should look like. You need to construct a similar string, substituting variables where the body contains submission-specific information

    So if my user name is "Finian" and password is "hello" then I can format a text variable similar to the example and substitute my name and password (and any other values) into the string. The following is a very primitive attempt to communicate with the server in question. Because the body is incomplete and the submitted information is not valid, the script can't work, but it does generate a response from the server.

    Code:
    dim user as c;dim pass as c
    user = "Finian";pass = "hello"
    dim postbody as c
    dim posturl as c
    posturl = "http://www.smsportal.co.za/httppost3.aspx"   
    postbody = "</form>"\
    + Crlf() + "</td></tr>"\
    + Crlf() + "<tr><td height=\"10\"></td></tr>"\
    + Crlf() +"<td><tr>"\
    + Crlf() + "<form method=\"POST\" action=\"http://www.smsportal.co.za/httppost3.aspx\">"\
    + Crlf() + "<input type=\"hidden\" name=\"Type\" size=\"20\" value=\"Bulk\">"\
    + Crlf() + "<Table border=1>"\
    + Crlf() + "<tr><td colspan=\"2\">Bulk SMS</td></tr>"\
    + Crlf() + "<tr><td>Username</td><td><input type=\"text\" name= '" + User + "' size=\"20\"></td></tr><!--You username -->"\
    + Crlf() + "<tr><td>Password</td><td><input type=\"text\" name='" + Pass + "' size=\"20\"></td></tr><!--You Password -->"
    ui_msg_box("",postbody)
    'submit the information to the server
    response = http_post(posturl,postbody)
    'show the server response in a msg_box
    ui_msg_box("",response.body)
    'write the server response to a file
    file.from_string("C:\temp\http_post_response.txt",response.body)
    end
    The http functions are documented, but just barely so. So there will likely be a lot of trial and error in this. There are also a bunch of functions that deal with processing URLs etc but I find it difficult impossible to determine how or whether they would/should be used in the context of these functions.
    Finian

  3. #3
    Member
    Real Name
    Walter
    Join Date
    Jun 2003
    Location
    South Africa
    Posts
    456

    Default Re: http_post

    Thanks Lenny,

    Looks like this one is more intersting than I thought it would be.
    I am going to give this a go this evening, I will keep posting the progress on this.

    Walter

  4. #4
    Member
    Real Name
    Walter
    Join Date
    Jun 2003
    Location
    South Africa
    Posts
    456

    Default Re: http_post

    Hello Lenny,

    In the end it was simpler than expected.
    This is what they were looking for.

    posturl = "http://www.smsportal.co.za/httppost3.aspx"
    postbody = "type=bulk"+ "&" +"username=xxx"+"&"+"password=xxxx"+"&"+"number=0000000000"+"&"+"message=test from cms new post"+"&"+"sendDate=25/Oct/2006"+"&"+"sendTime=10:31"

    '--> END OF BODY

    ui_msg_box("",postbody) '-->message to user before sending http_post
    'submit the information to the server

    file.from_string("C:\commercial merchants\data\sms_server_reply\http_post_preview.txt",postbody)'--> record details of post before sending

    response = http_post(posturl,postbody)'-->the actual post to your server

    'show the server response in a msg_box
    'ui_msg_box("",response.body)
    'write the server response to a file
    file.from_string("C:\commercial merchants\data\sms_server_reply\http_post_response.txt",response.body)'--> record reply from your server to file
    end

    Thanks for the help
    Walter

  5. #5
    Member
    Real Name
    Walter
    Join Date
    Jun 2003
    Location
    South Africa
    Posts
    456

    Default Re: http_post

    Hello Lenny,

    I have another question please.
    I receive data from the sms server in this format:

    <table cellspacing="0" rules="all" border="1" id="DataGrid">
    <tr>
    <td>SentID</td><td>PhoneNumber</td><td>Data</td><td>DateTime</td><td>CustomerID</td><td>SentStatus</td>
    </tr><tr>
    <td>8903130</td><td>+27000000000</td><td>This sms directly from cms application. Walter</td><td>10/25/2006 11:54:07 AM</td><td>None</td><td>Sent</td>
    </tr><tr>
    <td>8903131</td><td>+27000000000</td><td>This sms directly from cms application. Walter</td><td>10/25/2006 11:54:08 AM</td><td>None</td><td>Sent</td>
    </tr>
    </table>

    Is there any way to get these values into a table from here?

    Thanks
    Walter

Bookmarks

Posting Permissions

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