SYS(8009) - HTTP data transfer

Top  Previous  Next

Exchanges data with a web server over HTTP.

Syntax

SYS( 8009, cMethod, cUrl [, cData])

Parameters

cMethod

Specifies the HTTP 1.1 command that is sent to the web server. Valid values are:

 

Method

Description

GET

Returns the content for the specified Url. The Url can be a static web page, any binary file or any dynamic web handler. This includes ASP.NET, PHP, Web services, etc.

POST

Sends the content of cData to the web server and returns the response. The web server expects cData to be encoded as application/x-www-form-urlencoded. The STRCONV() function can be used to encode strings accordingly.

 

If the backend module has access to the raw request data, you can ignore the content type. Otherwise you need to encode your request accordingly.

 

Other less frequently uses commands are HEAD, PUT, DELETE, TRACE, and OPTIONS.

 

cUrl

Any valid web address in the form

 

http://server/resource?parameters

 

The Url can point to any server that is reachable from the computer or device. Mobile devices with internet connections, such as cell phones, can send and receive data across the internet. As the transfer uses the HTTP protocol, the content is not encrypted.

 

cData

Contains additional data that is sent with the request.

 

Some HTTP methods send additional information with the requests. The most common one is POST. When using such a method you must specify the cData parameter. Otherwise, your application might stop responding. For HTTP methods that do not expect additional data, such as GET, this parameter should be omitted.

Return value

Returns a string with the content of the specified web resource. The return value is NULL if any error occurred while processing the request.

Example

Local lcWeb

lcWeb = Sys(8009,"GET","http://guineu.foxpert.com")

MessageBox( Left(m.lcWeb,500) )

Remarks

You are not limited to transfer text data. For instance, you can have a web page that calls a Visual FoxPro COM server. The COM server could execute a query into a temporary DBF and then return the DBF file. In the same way you can transfer a DBF file to the server where server side scripts can process the content.

 

If you want to pass on state information to a VFP application running on the web server, you can use SAVE MEMORY to save all current variables. On the backend you can use RESTORE MEMORY to load the variable set into memory. This is especially useful when the remote script executes a query and query parameters have been stored in local variables.

 

Please note that your service provider might charge you for any internet traffic originating from your cell phone or mobile device. The ability to transfer data over the internet depends on your device, the connection and your service plan.

See also

SYS(8010) - FTP data transfer

STRCONV()