472,982 Members | 2,474 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,982 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 1607
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: yawnmoth | last post by:
Is it possible to send http requests with curl but not have curl wait for the response? The reason I ask is because I'd like to code a web app that can sorta start time consuming processes...
4
by: BinnyVA | last post by:
Hi, I am using PHP 5.1.2 with curl enabled. But whenever I try to use curl to fetch a url, it fails - 'curl_exec()' returns nothing. But if I try to execute the same file in CLI - like 'php...
4
by: Terry | last post by:
I'm using curl to invoke a php script on the same site/server. It works great, but if I call it again while it's still running, nothing happens. Why? Can that be fixed? Why use curl? To make...
9
by: devranger | last post by:
I am using the below CURL Function and can not figure out why it is not retruning the results from the post. Can anyone take a look and tell me what I may be doing wrong? I am just not seeing...
1
by: nothing1 | last post by:
I'm getting some warning using the code below: Error: failed to open stream: Permission denied in Code: function wwwcopy($url,$dirname){ $file = fopen($url, "r"); if (!$file) { ...
56
by: UKuser | last post by:
Hi, I'm not sure if this can be done as I've searched the web and this forum. I am using an online merchant provider and I must post certain variables to their webforms through a form on my...
4
by: rottmanj | last post by:
I am working on a revamp of a previous application that I have written in coldfusion. The application deals with RETS data. The issue that I am having is with using the curl option HTTP_AUTH and...
3
by: Sarah | last post by:
I was wondering if someone might be able to help me with this issue. I have a feeling this has something to do with my host's server settings as I used to be able to get CURL to follow redirects by...
5
by: DustinP | last post by:
I have installed PHP5 as ISAPI several times per every single guide I could find in the first 50 pages of results on google.. Server is Windows 2008 runing IIS7, phpinfo works and tells me the...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...

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.