Monday, August 02, 2004

Well here's what I learned from my first little experience with PHP & libcurl .....

base href="http://www.mctreas.org/"
// ACCESS DAYTON PUBLIC RECORDS SITE
$url = "http://www.mctreas.org/Message_IsProcessing.cfm";
$ch = curl_init(); // initialize curl handle
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
// allow redirects
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// return into a variable
curl_setopt($ch, CURLOPT_TIMEOUT, 3);
// times out after 4s
curl_setopt($ch, CURLOPT_POST, 1); // set POST method
curl_setopt($ch, CURLOPT_POSTFIELDS,
"streetnbr=1673&streetname=
earlham%20&own1=&parid=&taxyr=2003");
// add post fields

$result = curl_exec($ch); // run the whole process
print_r(curl_getinfo($ch));
echo "\n\ncURL error number:" .curl_errno($ch);
echo "\n\ncURL error:" . curl_error($ch);

curl_close($ch);
print $result;
?>



This little code right here did a basic post to a website and printed out the results from it or really gave me the page that it redirects to. It's the first step along this road and its a very good one. Oh, and to display code in a blog just take out a "<" and replace it with & l t ; Just smush it back together when you do.