OLE_GETWEBPAGE function
Description
An OLE function used to retrieve the contents of a webpage.
Syntax
retval = OLE_GetWebPage( url, method, payload, credentials, headers, timeouts, responseBody, otherOptions )
Parameters
Parameter | Description |
---|---|
url | (in) The web address of the webpage to retrieve (for the GET method) or to send data to (for other methods). |
method | (in) GET, POST, PUT, DELETE or PATCH. This parameter defaults to GET. |
payload | <Optional> (in) For a POST, PUT, or DELETE request, this is the POSTED data. This parameter defaults to NULL. |
credentials | <Optional> (in) If proxy authentication is needed, pass the credentials as username : @fm : password. This parameter defaults to NULL. See http://support.microsoft.com/kb/315909 for info on Proxy Authentication |
headers | <Optional> (in, out) On input, a 2-level @fm-delimited array of associated @vm-delimited header values. If specified, these values are sent when the HTTP request is initiated. This parameter defaults to NULL. On output, after a successful call, this parameter will return a dynamic array of the headers set by the server. Note: if multiple calls to ole_getwebpage are done, be sure to clear/reset this parameter between subsequent calls, otherwise the web request may fail. |
timeouts | <Optional> (in) Pass in the desired communication tiimeouts as a comma-delimited string of <resolveTimeout>,<connectTimeout>,<sendTimeout>,<receiveTimeout>, or a single "-1" to indicate the call should be asynchronous. The parameter defaults to NULL. |
responseBody | (out) Depending on the type of response (as specified by the web server), the responseBody will be set to the data returned as plain text, or an ArrayBuffer, or a binary "Blob", or a javaScript object. |
OtherOptions | <optional> (in) A 2-level @fm-delimited array of associated @vm-delimited optional values. See following table for available options. |
Starting with OpenInsight 10.2.2, the OLE_GETWEBPAGE_EQUATES contains equated names for the following supported options. You may use either the equated name, or the explicit option string.
OtherOptions Option String | Equated Name (10.2.2+) | Description |
---|---|---|
"ignore_errs" | OPTION_IGNORE_ERRS$ | If specified in field 1 of the OtherOptions parameter, this instructs ole_getwebpage to ignore errors and continue processing the request (as much as possible). The associated value in field 2 should be set to "1" |
"tlsprotocol" | OPTION_TLS_PROTOCOL$ | If specified in field 1 of the OtherOptions parameter, the associated field 2 value should contain one of the following: "tls11", "tls12", "tls13", "systemdefault", "ssl3", "tls" or their equated names: TLS_PROTOCOL_TLS11$, TLS_PROTOCOL_TLS12$, TLS_PROTOCOL_TLS13$, TLS_PROTOCOL_DEFAULT$, TLS_PROTOCOL_SSL3$, TLS_PROTOCOL_TLS$ |
"progid" | OPTION_SPECIFIC_PROTOCOL$ | (10.2.2+) If specified in field 1 of the OtherOptions parameter, the associated field 2 value should contain the protocol name to use (for example, 'Msxml2.ServerXMLHTTP.6.0' or SPECIFIC_PROTOCOL_SELECT_MSXML$) or the name of a specific protocol NOT to use, preceded by "-" (for example, "-WinHttp.WinHttpRequest.5.1" or SPECIFIC_PROTOCOL_REMOVE_WINHTTP$) |
Returns
The response from the URL
Remarks
This function originally used the MS ServerXMLHttp protocol. This function allows calls to SSL sites and can send authenticated requests.
Starting with release 10.2, this function was modified to use the WinHTTPRequest protocol instead, in order to support specification of additional security parameters (such as tls protocol). Unfortunately, the WinHTTPRequest protocol modifies the Content-Type header to always include a charset specification; if the receiving server is not expecting (or does not allow) this on the Content-Type header, your request may fail. If you must use a protocol that does not modify the Content-Type, you may specify an option starting with OpenInsight release 10.2.2. Use the option OPTION_SPECIFIC_PROTOCOL$ in the options field 1, and the option value SPECIFIC_PROTOCOL_REMOVE_WINHTTP$ in the associated options field 2. This will force OLE_GetWebPage to remove the WinHTTPRequest protocol and revert to the earlier ServerXMLHttp.
Example
* Available starting in OpenInsight 10.2.2: $INSERT OLE_GETWEBPAGE_EQUATES Declare Function Ole_GetWebPage url = "http://www.google.com" retval = ole_getwebpage( url ) Swap Char(13) : char(10) With @fm In retval Swap char(10) With @fm In retval Swap @fm With char(13) : char(10) In retval OSWrite retval To "C:\url.txt"