curl-and-php
RE: HTTPS and cURL in PHP
Date: Tue, 7 Sep 2004 17:15:32 +1000
OK I got it working. Thanks for your help.
Just in case it helps someone else. Here is my code to login to a
website and download txt file using https
$url = "https://...";
$postFields = "username=user&password=pass";
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_COOKIEJAR,"cookie.txt");
curl_setopt($ch,CURLOPT_COOKIEFILE,"cookie.txt");
curl_setopt($ch,CURLOPT_POST,TRUE);
curl_setopt($ch,CURLOPT_POSTFIELDS,$postFields);
curl_setopt($ch,CURLOPT_FOLLOWLOCATION,TRUE);
ob_start();
curl_exec($ch);
ob_end_clean(); // stop preventing output
$url = "https:// .. file.txt"
curl_setopt($ch,CURLOPT_URL,$url); // same curl handle
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
ob_start();
$response = curl_exec($ch);
ob_end_clean();
cheers
frank
-----Original Message-----
From: curl-and-php-bounces_at_cool.haxx.se
[mailto:curl-and-php-bounces_at_cool.haxx.se] On Behalf Of Daniel Stenberg
Sent: Monday, 6 September 2004 5:38 PM
To: using curl with PHP
Subject: RE: HTTPS and cURL in PHP
On Mon, 6 Sep 2004, Frank wrote:
> I did try to start the cookie parser as you mentioned and use the same
> handle to call the login page but I got same error.
My guide to successful login:
1. Use LiveHTTPHeaders with your browser and do eveything you want to
do.
2. Use the curl command line tool and its --trace-ascii option to login.
3. Compare that the outputs from 1) and 2) are sufficiently similar. As
long
as they differ and the site still complains you can continue mimicing
the
browser even closer, using the output from 1) as a guide.
-- Daniel Stenberg -- http://curl.haxx.se -- http://daniel.haxx.se Dedicated custom curl help for hire: http://haxx.se/curl.htmlReceived on 2004-09-07