curl-and-php
Re: Me again
Date: Wed, 18 Aug 2004 09:45:13 -0400
This is from the FAQ:
--------------
7.3 Can I perform multiple requests using the same handle?
With libcurl you can. With PHP/CURL you cannot. This is a limitation in the
PHP/CURL code. Therefore, you need to close each handle after each request
and create a new one for the following one.
I've heard rumours that this situation has been fixed in PHP5, but that is
unconfirmed.
-----------------
I seem to be doing this just fine with PHP/CURL under php version 4.3.8.
Here's a sample of what I mean:
$ch = curl_init();
while( something_to_do() ) {
$page = fetch_page($ch,$url,$form);
// do stuff with the page
// change $form or $url here
}
Inside fetch_page(), I reset several variables like so:
if( $posting ) {
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
} else {
curl_setopt($ch, CURLOPT_POST, 0);
curl_setopt($ch, CURLOPT_POSTFIELDS, NULL);
curl_setopt($ch, CURLOPT_HTTPGET, 1);
}
But it all seems to work.
Kirk
At 07:16 AM 8/18/2004, Daniel wrote:
>On Wed, 18 Aug 2004, Tig wrote:
>
>>That made the thing work.
>
>Neato.
>
>>Is there a manual bout curl commandline to php-curl convertion?
>
>Nope. We're waiting for you to start writing it! ;-)
>
>The command line options are often straight-forward to translate to the
>corresponding php-curl option.
>
>>I was also wondering if it is possible to open another url on the same
>>connection, so he keep all the vars in memory?
>
>This question has now made it into the FAQ:
>
> http://curl.haxx.se/docs/faq.html#7.3
>
>--
> Daniel Stenberg -- http://curl.haxx.se -- http://daniel.haxx.se
> Dedicated custom curl help for hire: http://haxx.se/curl.html
>
Received on 2004-08-18