Note: Use HTTPGet instead!
HttpGet provides most of the functionality of the low level HttpConnect/HttpGetEx combo, but is easier and more reliable as it handles all the connection setup/cleanup automatically.
o.HTTPGetEx(tcPage, @tcBuffer, @tnBufferSize, tcHeaders, tcFileName)
@tcBuffer
This is the result buffer that will contain data retrieved from the Web server. The size of this buffer depends on the input and output values of tnBufferSize
@tnBufferSize
This value determines the size of the result buffer returned. Pass in a size and HTTPGetEx will only return that many bytes or less. Pass in 0 and the buffer is dynamically sized to the request's size. On output this value will contain the actual size of the HTTP response.
tcHeaders
Optional - Allows you to specify custom HTTP headers to send to the server. Note these are client side headers.
Example:
"Referer: http://myserver.com/somelink.htm" + CRLF + ; "User-Agent: Rick's great Browser V1.0" +CRLF +; "Custom: Wonk it!"
Easier: Use the AddHeader() method to add headers.
tcFileName
Optional - A filename to cause the captured data to be streamed directly to a file rather than into the @tcBuffer variable. Use this for strings that will be large such as file downloads. tcBuffer must be passed in as "" and the size as 0 for this option to work
When the result returns you can also retrieve cHTTPHeader to see any HTTP headers that were returned from the server.
Other properties to check out:
nHTTPPort - If you want to use other ports than 80/443
nHTTPPostMode - URL Encoded or MultiPart forms
cHTTPHeaders - Returns HTTP headers of the result
nHTTPWorkBufferSize - Size of the chunks that HTTPGetEx uses to read data from the server
lHTTPCancelDownload - Flag that can be set to cancel a HTTPGetEx request
cResultCode - HTTP Header result code (200,500,404 etc.) that you can use to check for additional
oHTTP = CREATEOBJECT("wwHttp")
*** Connect to the server
oHTTP.HTTPConnect("www.west-wind.com")
*** Let's post some data TO the server
oHTTP.AddPostKey("Client","B")
oHTTP.AddPostKey("FromDate","01/01/96")
*** Initialize the variables that will be filled by HTTPGetEx
lcHTML=""
lnText=0
*** Send the POST data and retrieve HTTP result
lnResult=oHTTP.HTTPGetEx("/wconnect/wc.dll?wwDemo~ShowHours",;
@lcHTML,@lnText)
IF lnResult # 0
? lnResult, oHTTP.cErrorMsg
RETURN
ENDIF
? TRIM(lcHTML)
* ShowHTML( lcHTML )
oHTTP.HTTPClose() && Close the connection