Hello, I am in the process of learning PHP CURL and in doing some test
examples I am having some issues with CURL that I do not fully
understand.
I am doing a test to use CURL to post and return results from
"http://powersports.hon da.com/dealer_locator/dealer_locator. asp"
However it does not appear to be returning results from the CURL post
action. What CURL appears to be doing is finding the page
"http://powersports.hon da.com/dealer_locator/dealer_locator. asp",
becasue I can wirte any portion of the page to a file with fwrite after
curl_exec($ch); , but I can not see the redirected page after a post is
done to retrun the results via fwrite. I have CURLOPT_FOLLOWL OCATION,
true so it should be finding the redirected pages.
The same code works fine if I just change $data to zip= for
"http://www.suzukicycle s.com/DealerLocator/".
Can some help on why the below code may not be working on
"http://powersports.hon da.com/dealer_locator/dealer_locator. asp" and
what I can do to get it working or how to go about debugging this so
that I can figure out why it is not working?
You can see the one that is working here:
// this is for suzuki
http://www.subdomain.tetrahost.net/test/test4.php
Your help is much appreciated. This one is driving me crazy.
Thank you!
devranger
<?php
$data=array("Zi pCode=90277");
$url="http://powersports.hon da.com/dealer_locator/dealer_locator. asp";
// create a new curl resource
$ch = curl_init();
// set URL and other appropriate options
curl_setopt($ch , CURLOPT_URL, $url);
curl_setopt($ch , CURLOPT_RETURNT RANSFER, true);
curl_setopt($ch , CURLOPT_FOLLOWL OCATION, true);
curl_setopt($ch , CURLOPT_USERAGE NT, 'Test0.1');
curl_setopt($ch , CURLOPT_POST, true);
curl_setopt($ch , CURLOPT_POSTFIE LDS, $data);
// grab URL, and return output
$Contents = curl_exec($ch);
// close curl resource, and free up system resources
print_r ($Contents);
echo 'done';
?>