note 26239 modified in function.curl-setopt by danbrown
| From: | danbrown@php.net | Date: | Sun, 17 May 2009 17:35:22 +0000 |
| Subject: | note 26239 modified in function.curl-setopt by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-155003@lists.php.net to get a copy of this message | ||
beware that not all cURLlib constants are supported under php :
e.g. CURLOPT_PROGRESSFUNCTION or CURLOPT_WRITEDATA are not supported.
CURLOPT_WRITEFUNCTION, although undocumented is supported. It takes the name of a user_defined
function.
the function should take two arguments (the curl handle, and the inputdata) and return the length of
the written data
e.g.
<?php
function myPoorProgressFunc($ch,$str){
global $fd;
$len = fwrite($fd,$str);
print("#");
return $len;
}
curl_setopt($ch,CURLOPT_WRITEFUNCTION,"myPoorProgressFunc");
?>
Also be aware that CURLOPT_WRITEFUNCTION does NOT take the CURLOPT_FILE as a parameter!
in curl lib it would take CURLOPT_WRITEDATA but this is not supported by php; that's why I use
"global $fd;" in my exemple function.
CURLOPT_HEADERFUNCTION works the same, and is guaranteed to receive complete header lines as input!
Hope this helps
Ivan
--was--
beware that not all cURLlib constants are supported under php :
e.g. CURLOPT_PROGRESSFUNCTION or CURLOPT_WRITEDATA are not supported.
CURLOPT_WRITEFUNCTION, although undocumented is supported. It takes the name of a user_defined
function.
the function should take two arguments (the curl handle, and the inputdata) and return the length of
the written data
e.g.
function myPoorProgressFunc($ch,$str){
global $fd;
$len = fwrite($fd,$str);
print("#");
return $len;
}
curl_setopt($ch,CURLOPT_WRITEFUNCTION,"myPoorProgressFunc");
Also be aware that CURLOPT_WRITEFUNCTION does NOT take the CURLOPT_FILE as a parameter!
in curl lib it would take CURLOPT_WRITEDATA but this is not supported by php; that's why I use
"global $fd;" in my exemple function.
CURLOPT_HEADERFUNCTION works the same, and is guaranteed to receive complete header lines as input!
Hope this helps
Ivan
http://php.net/manual/en/function.curl-setopt.php