Difference between revisions of "POSTURL()"

From Lianjapedia
Jump to: navigation, search
Line 3: Line 3:
  
 
==Syntax==
 
==Syntax==
POSTURL(<expC1> [, <expN> [, <expO> &#124; <array> [, expC2>]]])
+
POSTURL(<expC1> [, <expN> [, <expO> &#124; <array> [, <expC2> [, <expC3>]]]])
  
 
==See Also==
 
==See Also==
Line 22: Line 22:
 
|-
 
|-
 
|<expC2>||Filename or character expression that will be sent as the POST body||"myfilename.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"
 
|-
 
|-
 
|}
 
|}
Line 28: Line 30:
 
<code lang="recital">
 
<code lang="recital">
 
// send a soap request
 
// send a soap request
response = posturl("http://www.myserver.com/somewebservice.aspx", ;
+
responsefile = posturl("http://www.myserver.com/somewebservice.aspx", ;
 
                           30, ;
 
                           30, ;
                           array("type" => "Content-Type: text/xml"), ;
+
                           array("type" => "Content-Type: application/soap+xml", "host" => "Host: localhost"), ;
                           "somefilename.xml")
+
                           "somefilename.xml","response.xml")
 
+
if len(response) = 0   
+
    // no data was returned
+
endif
+
  
 
// submit a form
 
// submit a form

Revision as of 13:06, 6 March 2014

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"), ;
                           "somefilename.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