POSTURL()

From Lianjapedia
Jump to: navigation, search

Purpose

Function to send an HTTP POST request to the specified URI

Syntax

POSTURL(<expC1> [, <expN> [, <expO> | <array> [, <expC2> [, <expC3>]]]])

See Also

AT(), ATNEXT(), FCLOSE(), FCREATE(), FERROR(), FGETS(), FILETOSTR(), FOPEN(), FPUTS(), FREAD(), FREADSTR(), FWRITE(), GETURL(), ISSERVER(), JSON_DECODE_FILE(), SUBSTR(), STUFF(), STR(), STREXTRACT(), STRTOFILE(), STRTRAN(), STRZERO(), TRIM(), XML_DECODE_FILE()

Description

The POSTURL() function sends an HTTP POST request to the specified URI.

Parameter Description Example
<expC1> Fully qualified URI "http://www.myserver.com/mywebservice.aspx"
<expN> The timeout in seconds for the request (default 30). Set this to 0 for no timeout. 30
<expO> |
<array>
By default the data is sent as "text/plain" in the HTTP body but you can add custom headers to the object/dynamic array and POST SOAP requests and read the response from the remote server returned as a string of text array("type" => "Content-Type: text/xml")
<expC2> Filename or character expression that will be sent as the POST body "myfilename.xml"
<expC3> Filename into which response will be written "response.xml"

Example

// send a soap request
responsefile = posturl("http://www.myserver.com/somewebservice.aspx", ;
                           30, ;
                           array("type" => "Content-Type: application/soap+xml", "host" => "Host: localhost"), ;
                           "requestdata.xml","response.xml")
 
// submit a form
response = posturl("http://www.myserver.com/someformsubmission.rsp", ;
                           30, ;                              
                           array("type" => "Content-Type: application/x-www-form-urlencoded"), ;
                           "name=barry&product=lianja")                                         
if len(response) = 0    
    // no data was returned
endif