curl-and-php
New To Curl - Trouble posting fields
Date: Wed, 29 Nov 2006 20:48:11 -0500
Hi,
I'm new to curl and I'm having some MAJOR trouble figuring this out.
I need to download the first page of a remote site and retrieve it's
fields. Then "fill-in" one of those fields with the letter E and post
the form (the E tells the form what type of records I need). Posting
the first form, sends you to a second page (form). On the second page
there are more fields, I need to enter certain data into those fields
and post that form. Posting the second form, sends you to a third page
(form).
The third form contains the data that I'm after. Until the third page
contains the phrase "End Of Data" (yes they actually display that on the
web page), I need to keep re-loading this third page.
I've got my script successfully retrieving the first page and parsing to
get all the fields. I've built the "postfields" string and what I'm
attempting to pass looks the same as what is in the request when I load
the page manually (I have LiveHTTP Headers Extension installed for Firefox).
When the script attempts to post the first form (retrieve the second
page), the remote server acts like it doesn't understand what to do.
The only thing I can see is that when posting the form manually, it does
use cookies. But when I use my Curl script, I don't see anything show
up in the cookies folder on my server. And even AFTER I actually get it
to download the cookies, I'm still not sure how to get get to send those
cookies back to the server when it's time.
I'm using the following to indicate where to keep the cookies:
$jar = '/curl-cookies/cookie.txt';
// ? where to save [Set-Cookie] (str, path + file name)
curl_setopt ( $io, CURLOPT_COOKIEJAR, $jar );
// ? where to read and send [Cookie] (str, path + file name)
curl_setopt ( $io, CURLOPT_COOKIEFILE, $jar );
Here's all the info retrieved from LiveHTTP:
http://4.43.65.248/autoform.asp
POST /autoform.asp HTTP/1.1
Host: 4.43.65.248
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.8)
Gecko/20061025 Firefox/1.5.0.8
Accept:
text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: http://4.43.65.248/autoform.asp?app=cvr
Cookie: ASPSESSIONIDQCABRSSD=CBBJDIACAHPEEBBAHEAPEDKK
Content-Type: application/x-www-form-urlencoded
Content-Length: 46
HTTP/1.x 200 OK
Server: Microsoft-IIS/5.0
Date: Thu, 30 Nov 2006 01:35:01 GMT
Connection: close
Content-Type: text/html
Expires: Thu, 30 Nov 2006 01:33:59 GMT
Cache-Control: private
_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2006-11-30