471,075 Members | 754 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,075 software developers and data experts.

Please Help With A Curl Issue

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.honda.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.honda.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_FOLLOWLOCATION,
true so it should be finding the redirected pages.

The same code works fine if I just change $data to zip= for
"http://www.suzukicycles.com/DealerLocator/".

Can some help on why the below code may not be working on
"http://powersports.honda.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("ZipCode=90277");
$url="http://powersports.honda.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_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_USERAGENT, 'Test0.1');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);

// grab URL, and return output

$Contents = curl_exec($ch);

// close curl resource, and free up system resources

print_r ($Contents);

echo 'done';
?>

Nov 29 '06 #1
1 1477
You may need to post it to the url referenced in the original form's
action attribute. Then to make it work, CURLOPT_POSTFIELDS should be
set to a string value instead of an array.

devranger wrote:
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.honda.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.honda.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_FOLLOWLOCATION,
true so it should be finding the redirected pages.

The same code works fine if I just change $data to zip= for
"http://www.suzukicycles.com/DealerLocator/".

Can some help on why the below code may not be working on
"http://powersports.honda.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("ZipCode=90277");
$url="http://powersports.honda.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_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_USERAGENT, 'Test0.1');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);

// grab URL, and return output

$Contents = curl_exec($ch);

// close curl resource, and free up system resources

print_r ($Contents);

echo 'done';
?>
Nov 29 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by BinnyVA | last post: by
4 posts views Thread by Terry | last post: by
9 posts views Thread by devranger | last post: by
1 post views Thread by nothing1 | last post: by
56 posts views Thread by UKuser | last post: by
4 posts views Thread by rottmanj | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.