Here is a function that you can use to POST and return information to/from a remote site.
VIEW SOURCE
/chrisg/tools/view-sendpost.asp
DOWNLOAD SOURCE
/chrisg/tools/download.asp?file=sendpost.asp
SEE IT IN ACTION
/chrisg/tools/sendpost.asp
If you try the above "see it in action link" you will see the script has POSTed the name/value pair of "test=Yay!", and this has been reflected in the remote page that has been called (outputvars.asp, an example from a previous article) which outputs all the current request variables. Take a look at the results and you will also see the REQUEST_METHOD was POST.
How was it done?
Microsoft has kindly created a lovely component for working with XML that has a nice set of tools (as a side effect) for communicating with remote servers, the script uses these tools to send variables and receive the HTTP output.
The script
The script consists of a function call will supplies a URL and the information to post to a function called "sendPost".
SendPost creates an instance of the XMLHTTP object (line 9), and then uses the Open method (line 16) with the parameters "POST" to say we want to post the information (change to GET if you want to use GET) and the URL we wish to talk to.
Because I am using POST I need to add the header in line 17, if you are using GET ommit this line.
Lines 18 and 21 are where we send the information and the response is returned to our script.
Extending the script
This as it stands is a reusable function for posting and receiving the response. Possible uses are submitting information to multiple search engines and returning the results, or posting competition entries to a third party while retaining the visitor on your own site.
If you want to work with the response you will probably need to use regular expressions, which is outside the scope of this article, check out the following links.