Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Send data to a Web Page
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Applications Internet
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Divers
Thread ID:
01500623
Message ID:
01501354
Vues:
82
Hi Koen,

Here is a sample code that sends GET request:
CLEAR
CLEAR ALL
SET MEMOWIDTH TO 120

*LOCAL oHttp As MSXML2.ServerXMLHTTP
*oHttp = CreateObject('MSXML2.ServerXMLHTTP')

LOCAL oHttp As Msxml2.XMLHTTP
oHttp = CreateObject('Msxml2.XMLHTTP')

WITH m.oHttp
	.Open('GET', "http://www.levelextreme.com", 0, '', '')

	.Send()

	? oHttp.StatusText
	? oHttp.GetAllResponseHeaders()
	? oHttp.ResponseText
ENDWITH
There probably should be some subtle differences between MSXML2.ServerXMLHTTP and Msxml2.XMLHTTP, but so far I find them interchangeable.

Sending a POST request is almost same easy. Replace the verb in .Open(...) with POST. If any data need to be passed with a request, there are two ways of doing that.

a) By setting HTTP request headers -- the length of data per header is limited.
b) By sending HTTP request's body as.Send( body ). The length of data that can be sent is less limited in this case.

A receiving script certainly must have some knowledge of what kind of data is coming -- just to be able to process it properly and send back a response.

HTTP requests are sent either synchronously or asynchronously. With VFP you probably choose the first way. The program execution is blocked until a request return.

I guess MSDN links fluctuate; this happened before. Here is a few more:
http://msdn.microsoft.com/en-us/library/ms754586(v=VS.85).aspx
http://msdn.microsoft.com/en-us/library/ms762278(v=VS.85).aspx
http://msdn.microsoft.com/en-us/library/ms766431(v=vs.85).aspx

In any case, search MSXML2.ServerXMLHTTP or Msxml2.XMLHTTP in combination with POST -- there's plenty of useful links around.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform