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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Redirect form data to 3rd party site 3

Status
Not open for further replies.

johnwm

Programmer
Feb 7, 2001
8,469
GB
Bit difficult to explain this - probably why I can't get my head round it at all!

I'm trying to get input from a form on site1 (normal asp back end under my control) and progammatically send the info from the server to a 3rd party site so it looks like a form input. I need the page output from the 3rd party site returned to my server, reprocessed and re-served to my page.

My client (owner of site1) has a trade account with a parcel carrier. He wants his site to collect bookings via site1 and automatically book them on the carrier's site. This involves logging in to his account, doing address confirmation and booking the collection, which needs to interact live with site1's input. The carrier doesn't have any published APIs. Their reply was 'someone said it could be done with a screenscrape, mumble, mumble'. I got the feeling that I hadn't got the problem over to them, and they weren't that bothered about sorting an answer.

I've been looking at it for 3 days. I've looked at Winhttp and xmlhttp, but just can't get a handle on the process. I've googled until my fingers are bleeding, but to no avail. Has anyone done this or similar, and if so what sort of route have they used?

___________________________________________________________
If you want the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
Steam Engine Prints
 
Hey John,

Is the site a SSL site?

XMLHTTP will be what I believe you're going to want. It's been awhile sense I've done anything like this but it's pretty straight forward. The SSL part may make it interesting but as I recall that is simply logging in via the same method

A simplistic example of that would be something like this to get the temp for a zip from the weather.com site
Code:
Dim xmlhttp
Set xmlhttp = Server.CreateObject("MSXML2.ServerXMLHTTP")

xmlhttp.open "POST","[URL unfurl="true"]http://www.weather.com/search/enhanced",False[/URL]
xmlhttp.setRequestHeader "Content-Type","application/x-[URL unfurl="true"]www-form-urlencoded"[/URL]

xmlhttp.send "where=53142"
Dim strEPDQ1
strEPDQ1 = xmlhttp.responseText
Set xmlhttp = Nothing

Response.write strEPDQ1

[sub]____________ signature below ______________
The worst mistake you'll ever make is to do something simply the way you know how while ignoring the way it should be done[/sub]
 
If the parcel carrier does not provide some variety of web service or an API, then there is no dependable way to construct this interface. Because, a "screen scrape" means that you are parsing the HTML returned by their server, that is parsing a web page, and the day after you get the parsing to work, a marketing manager at the parcel carrier will decide to change the web page, and the parsing will break.

In the face of this, it might be worth more attempts to contact someone at the parcel carrier in the hope that they really do have an API. Maybe your client, who has a business relationship with the parcel carrier will have better leverage than yourself, the humble developer.

The process is the same whether you are scraping or using an API, or a web service. Your client web site has a form. The form is submitted to your script on your web server. When you process the form data, you use WinHTTP, or whatever scriptable HTTP client you have, and POST the data in a request to the parcel carrier. Their web site RESPONDS with a document, maybe it is a web page, maybe it is a SOAP document, maybe it is a comma delimited sequence of name/value pairs. Whatever HTTP client you are using will have a method for reading this document, either using the DOM or as a string. This response is parsed in your script to obtain whatever confirmation data you need. Then you use that data to build your web page which is your response to the first form submission.
 
Thanks guys, you've given me a starting point - I realise that scraping is a horrible way of doing it. I will try again for APIs tomorrow and failing that I'll have a look at DOM on the basis that developers will resist changing element IDs, even when there are 'pretty' changes. I'll come back if I get more info

___________________________________________________________
If you want the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
Steam Engine Prints
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top