curl-and-php
cURL HTTP POST problem
Date: Sun, 04 May 2003 20:35:21 -0700
I am a CURL newbe and I am frustrated because I can't get HTTP POST to work using cURL. I used an HTTP monitor (NAVISCOPE) to watch the manual POST transaction using Internet Explorer to see exactly what was POSTed. The form is at:
http://lapublichealth.org/rating/
Here are the results:
POST http://lapublichealth.org/rating/ratesearchaction.cfm HTTP/1.0
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-powerpoint, application/x-shockwave-flash, application/pdf, application/msword, application/vnd.ms-excel, */*
Referer: http://lapublichealth.org/rating/
Accept-Language: en-us
Content-Type: application/x-www-form-urlencoded
Proxy-Connection: Keep-Alive
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; Q312461; .NET CLR 1.0.3705; .NET CLR 1.1.4322)
Host: lapublichealth.org
Content-Length: 57
Pragma: no-cache
dba=&address=&city=&zipcode=&score=100&sort=dba&B1=Submit
The last line is the actual post field. I actually cut and pasted that line (to avoid typing mistakes) into CURLOPT_POSTFIELDS as follows:
curl_init();
curl_setopt($ch, CURLOPT_URL,"http://lapublichealth.org/rating/ratesearchaction.cfm");
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 3); //times out after 4s
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "dba=&address=&city=&zipcode=&score=100&sort=dba&B1=Submit");
$result=curl_exec ($ch);
curl_close ($ch);
echo "result=".$result;
?>
This code produces no result:
result=''
I would appreciate any ideas you might have!
Phil
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
Received on 2003-05-05