Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Automatically send form data?

Status
Not open for further replies.

buddyrich2

Technical User
Apr 12, 2006
87
0
0
US
I have an application that needs to send form data to a certain URL. I need to do it on the "backend" instead of displaying the form (and subsequent results). Is there a way to do this in VFP? I also need to capture the results (CSV file) and parse it into a table.

Can anyone help me? Thanks.
 
Hi,

If you want to automate a webpage with data my best bet for you is to visit WestWind / Rick Strahl has made some excellent procedures for this.

To transform the results from CSV format into a DBF there are several solutions. Could you elaborate the CSV file a little bit, viz. is the structure of the file known and fixed e.s.o. Best to give an example
Regards,
Jockey(2)
 
I would second the suggestion of visiting Rick Strahl's page, excellent resource. The IE automation looks interesting for parsing out the page but seems a little heavy handed if you just want to POST the data, also I would test it to see if it's IE version dependant. I've been using HttpRequest on Win2k and XP machines (haven't tried Vists) for years with success. If you know what the data is or have another means of parsing what you're looking for then HttpRequest might fit the bill.

Code:
loHTTP = CREATEOBJECT("WinHttp.WinHttpRequest.5.1")	
loHTTP.Open("POST", "SomeUrl.com", Asynchronous)	
loHTTP.SetCredentials("UserName", "Password", 0)
loHTTP.SetClientCertificate("CertificateName")
loHTTP.SetRequestHeader("content-type", "application/x-[URL unfurl="true"]www-form-urlencoded")[/URL]
loHTTP.SetProxy(ProxySetting, "ProxyServer", "ByPassList")	
loHTTP.Send("YourDataValuePairs")
loHTTP.Status						&& Setting TNetHttp's response code, hopefully it's 200
IF loHTTP.StatusText == 200 THEN	
  * you got your data
  YourCsvData = loHTTP.ResponseBody
ELSE
  * something didn't work
ENDIF

Some of those lines you can eliminate depending of if you need to set a proxy from the client or submit credentials and/or certificate to the server. Would also suggest putting some error trapping around those calls but you should get the idea and have enough to play with if you're interested.

Wish you success with whatever solution you go with.

Ralph Kolva
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top