ASP Post data to URL
ASP Best Practices
ASP function to post form data to a URL and return the content.
Date : 2006-04-05
The first time I needed this function it was for posting data to Authorize.net for payment processing but there are many uses. The only caveat is the data sent must be formatted correctly. I've given a simple example of how it's used also.
Here it is:
Function PostTo(Data, URL)
Dim objXMLHTTP, xml
On Error Resume Next
Set xml = Server.CreateObject("MSXML2.ServerXMLHTTP.3.0")
xml.Open "POST", URL, False
xml.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
If xml.readyState <> 4 then
If Err.Number = 0 AND http.Status = 200 then
PostTo = xml.responseText
PostTo = "Failed"
Set xml = Nothing
PostData = "encoding=UTF-8&firstname=" & firstname & "&lastname=" & lastname & "&email=" & email & ""
rslt = PostTo(PostData,"http://www.myurl.com/formhandler.asp")
No comments yet