curl-and-php
using curl from another class?
Date: Sun, 23 Jul 2006 19:44:23 -0500
Hello all,
I am trying to use my curl within my own class in php5, and believe I
should be quite close; the problem seems to be that the 'read_header'
function is not found within the class. I have tried replacing it with
this->read_header, this::read_header, self::read_header, and so on
without luck. Can this be done, or am I on the wrong track here?
<?php
test_curl
{
public $result;
public $result_header;
public $result_error;
public funtion test_curl($ch) {
curl_setopt($ch, CURLOPT_URL, 'http://testsite.int/');
// Set callback function for headers
curl_setopt($ch, CURLOPT_HEADERFUNCTION, 'read_header');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
ob_start();
$this->result = curl_exec($ch);
$this->result_header = ob_get_contents();
ob_end_clean();
if ($error = curl_error($ch)) {
echo "Error: $error<br />\n";
}
# $this->result_error = $error;
}
static function read_header($ch, $string)
{
$length = strlen($string);
echo "$string";
return $length;
}
}
$ch = curl_init();
$test = new test_curl($ch); # this result in Error: failed writing
header;
?>
I did also try to extend curl_init without luck:
class my_curl extends curl_init {
private $header;
private $result_header;
}
_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2006-07-24