curl-and-php
Re: Can cURL be used to post massaged form data and land the user on an external partner page?
Date: Mon, 10 Apr 2006 12:09:00 -0700
Hi Colin,
I'll make a stab at it (caveat: I use Curl from command-lines (called from
Perl) so it's a completely different environment, but I think the usage
principles are the same.)
I had (what I think was) the same problem, and the way I got thru it was to
write the STDERR contents to an external file - Ie, The CURL output that
looks like this;
* About to connect() to conf1.centra.com port 80
* Connected to conf1.externalsite.com (222.244.222.111) port 80
> POST /SiteRoots/main/index.jhtml?sessionid=113886078395524168 HTTP/1.1
User-Agent: curl/7.12.0 (i386-pc-win32) libcurl/7.12.0 OpenSSL/0.9.7c
zlib/1.2.1
Host: conf1.extsite.com
Pragma: no-cache
Accept: */*
Cookie: ASPSESSIONIDQQCDQASQ=ABEDOPA;
[---]
Pragma: no-cache
< Location:
http://conf1.externalsite.com/SiteRoots/main/User/Homepage.jhtml?this=that&sessionid=1199980
< Expires: -1
[---]
I then parse the location reference and follow the session path (and of
course setting up the username and password params in the "-d" section of
the CORL call.)
Maybe I'm wrong, but I believe the actual 'landing' of the user onto a web
page is pretty much up to the web server you're attempting to hit. Some
web programmers will leave the HTTP-redirect to the browser, and some will
attempt it via the server- because some user's don't have their browser set
to automatically re-direct.
I don't think SSL is actually the issue because CURL seems (in the years
I've used it) to be pretty good at negotiating secure site (if you have the
version compiled for SSL).
Hope this helps-
KC
On 4/9/06, Colin Catlin <colin_at_theideastore.us> wrote:
>
> Hi,
>
>
>
> In essence using php I need to massage the data I get from a form post on
> my site, and then afterwards using php, post that data and the user on to an
> external partner page. The page is a https page. Like I said, I want to
> post the data and the user to the external partner page. Can I do this with
> cURL?
>
>
>
> What I can do is "post" to an https page using curl and get a return. But
> in truth I'm not actually on that external page, nor is the user.
>
>
>
> The external page I'm posting to is an https page, so I need to land the
> user on that page as well as post the data to that page. They need to land
> on the external page to continue their process and so that the bottom of the
> page shows the padlock and secures a follow up post made from the external
> page as part of the process.
>
>
>
> I can't use a standard location redirect, because it breaks security to
> show the name value pairs in the url.
>
>
>
> I've tried:
>
>
>
> curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
>
>
>
> But it doesn't seem to actually do anything that I can see. As it doesn't
> actually follow the location. Being new it's possible I don't understand
> this, I just read this in a few old threads here.
>
>
>
> I've searched on this topic, but nobody seems to provide any answers and
> everyone seems to dance around the question, a lot.
>
>
>
> Can it be done? Is curl the right tool to use? Should I be using
> something else? It seems like the right thing, if it just posted and pastd
> the control back to the user rather than returning to the script.
>
>
>
> Thanks for any pointers and help!
>
>
>
> Cheers and best regards,
>
>
>
> -Colin
>
>
>
> - Start of code -
>
>
>
> $ch = curl_init ();
>
> curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
>
> curl_setopt($ch, CURLOPT_URL, $url);
>
> curl_setopt($ch, CURLOPT_POST,1);
>
> curl_setopt($ch, CURLOPT_POSTFIELDS, $postvars);
>
>
>
> // perform post
>
> $output=curl_exec($ch);
>
> curl_close($ch);
>
>
>
> - End of code -
>
>
>
>
>
>
>
>
>
>
>
>
>
> _______________________________________________
> http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
>
>
>
_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2006-04-10