:Command()
Class
Syntax
:Command( cCommand, cServer, cResource, [cParams], [cHTTPVer] ) --> Server Response
Parameters
|
|
cCommand |
HTTP Command: HEAD, OPTIONS, PUT, GET, POST, etc. |
|
|
cServer |
Base URL to the Server (ie. www.Apareon.com) |
|
|
cResource |
Specific Resource (page, cgi, application, etc.) to send cCommand to. |
|
|
cParams |
Optional: Parameters to send to Server for processing. Usage depends on Command. |
|
|
cHTTPVer |
Optional: HTTP version. Defaults to :HTTPVersion |
Return
Returns the response form the Server.
If an error occurred, the return value is NIL
Description
The :Command() Method allows a client application to communicate directly with a Server.
This provides the ability to automate processes such as filling out Web-based forms, queries, etc.
Example:
#Include "CSKeys.ch"
#Include "ASocksKey.ch"
#Include "aSocksConst.ch"
//*******************************
Procedure Main( )
//*******************************
? SendCommand("POST", "aCGI.Apareon.com", "/cgi-bin/ZipCode.cgi", "CITY=Pittsburgh&STATE=PA", "1.0")
Inkey(0)
Return
//*******************************
Function SendCommand ( cCommand, cURL, cPage, cParam, cHTTP_Ver )
//*******************************
Local cResponse := ""
Local x := 0
Local oHTTP := aprHTTP():New(ASOCKS_LICENSE_KEY,CSTOOLS_LICENSE_KEY)
// Open a connection to remote Server
If oHTTP:Connect(cURL,80,15,HTTP_OPTION_KEEPALIVE)
// Send a Command to the remote server
cResponse := oHTTP:Command( cCommand, cUrl, cPage, cParam, cHTTP_Ver )
If cResponse = NIL
cResponse := oHTTP:cErr
EndIF
oHTTP:Disconnect()
Else
cResponse := oHTTP:cErr
EndIf
oHTTP:Destroy()
Return cResponse