473,793 Members | 2,894 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.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';
?>

Nov 29 '06 #1
1 1646
You may need to post it to the url referenced in the original form's
action attribute. Then to make it work, CURLOPT_POSTFIE LDS 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.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';
?>
Nov 29 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
12152
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 without the user having to wait. I'm doing this (with fsockopen) by sending an http request to a page that does the time consuming stuff and then immediatly closing, without having read any of the response. This way, I don't have to wait for the...
4
12174
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 curl.php', the script works properly. However if I try it in a browser, nothing is returned. The code is...
4
5563
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 it run in the background. My host can't use exec nor flush the output to the browser. But, I can use curl and timeout.
9
2026
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 it. As you can see at the bottom of the script if (strstr($Line, 'HOUSTON YAMAHA MOTORSPORTS')) then it is reading the correct page, otherwise if (strstr($Line, 'Yamaha Dealer Locator')) then it is reading the incorrect page of the initial URL...
1
4704
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) { echo"<font color=red>Failed to copy $url!</font><br>"; return false;
56
7247
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 website. The issue is that I need to gauge whether a user has any items in their basket to decide which page I redirect them too. I could
4
12081
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 CURLAUTH_DIGEST. When attempting to authenticate against the server. No matter what I try, my authentication always fails. I have made sure to validate the auth information. In my testings, I have also verified that curl can authenticate via the...
3
15674
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 setting CURLOPT_FOLLOWLOCATION set to true. I had a problem with my host's updating something in the past that gave me the error "CURLOPT_FOLLOWLOCATION cannot be activated when in safe_mode or an open_basedir is set". My host worked on the...
5
9581
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 configuration.. but there is an issue.. i see the following.. Configuration File (php.ini) Path C:\Windows Loaded Configuration File C:\php\php.ini PHP in installed to C:\php and the php.ini ONLY exists in that location and the permissions for...
0
10433
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10212
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10161
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9035
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7538
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5436
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4112
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3720
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2919
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.