Why is data from an AppleScript is not getting into a web form?

Howdy. I work at a publishing company where 1/3 of the company are on Macs but we have a MicroSoft and .Net centric IT staff. A lot of the applications they developed (like a time manager so you can sign in/out from your desktop) are not available for us Mac users. (Commiserate with me brothers and sisters). Anyway I’m working on developing a desktop based app in AS that’ll let the Mac users manage the various web forms from one place and retrieve the data. (We’re going to use REALBasic as a UI/front end. So I started putzing around with filling web forms from AS and wrote this script this morning:

display dialog “” default answer “Enter food name”
set theFoodEaten to text returned of result as string

set calCounterDefaults to “keys=” & theFoodEaten & “&search_type=and”

tell application “Internet Explorer”
Activate
OpenURL “http://www.caloriescount.org/cgi-bin/calorie_calculator.cgi” FormData (calCounterDefaults)
end tell

works fine. However when I try to do something similar to one of the intranet forms the data doesn’t get posted to the form entry boxes or sent. The only difference is that the data is not being posted to a cgi form and then on to a db, the IT group is using ASP to get the data from the form and pass that along to a SQL database. Any clue as to why the data I am setting in AppleScript is not getting put into the form?

Hi!

IE is not a very reliable tool (it doesn’t post a “referrer”, nor cookies, nor blah), and it will die sooner than later. Have you tried “curl”?

set userAgent to quoted form of "Mozilla/4.0" --> for example
set theReferrer to quoted form of "http://www.foo.com/foo.html" --> the page where is the form
set theCookies to quoted form of "foo1=value1;foo2=value2;foo3=value3" --> cookies, if you need'em
set URLEncodedFormData to quoted form of "var1=value1&var2=value2&var3=url%20encoded%20data" --> the POST data
set URLApp to quoted form of "http://www.foo.com/foo.cgi" --> form's "action"

do shell script "curl -A " & userAgent & " -e " & theReferrer & " -b " & theCookies & " -d " & URLEncodedFormData & space & URLApp & " -o /tmp/submitResult.html"