Zamysł był taki, aby było prościej i szybciej, czy się udało?
class curl_exception extends Exception {} class curl { private $handle; private $url=''; private $path=''; // cookie path private $userAgent=''; public function __construct($url='') { if (!function_exists('curl_init')) { throw new curl_exception('Curl jest wyłączony'); } $this->handle = curl_init(); $this->setUrl($url); } } public function setUrl($url) { $this->url = $url; $this->setOpt(CURLOPT_URL, $url); return $this; } public function getUrl() { return $this->url; } public function setCookiePath($path) { throw new curl_exception('Brak dostępu do ścieżki'); } $this->path = $path; $this->setOpt(CURLOPT_COOKIEJAR, $path.'/cookie.txt')->setOpt(CURLOPT_COOKIEFILE, $path.'/cookie.txt'); return $this; } public function getCookiePath() { return $this->path; } public function setOpt($option, $value) { curl_setopt($this->handle, $option, $value); return $this; } public function setPost($string) { $this->setOpt(CURLOPT_POST, true)->setOpt(CURLOPT_POSTFIELDS, $string); return $this; } public function setUserAgent($agent) { $this->userAgent = $agent; $this->setOpt(CURLOPT_USERAGENT, $agent); return $this; } public function getUserAgent() { return $this->userAgent; } $exec = curl_exec($this->handle); if ($this->getErrno()) { throw new curl_exception($this->getError()); }else{ return $exec; } }else{ throw new curl_exception('Url jest wymagany!'); } } private function getError() { return curl_error($this->handle); } private function getErrno() { return curl_errno($this->handle); } public function getHandle() { return $this->handle; } } class curl_multi { private $handle; public function __construct() { if (!function_exists('curl_multi_init')) { throw new curl_exception('Curl jest wyłączony'); } $this->handle = curl_multi_init(); } public function addHandle(curl $obj) { curl_multi_add_handle($this->handle, $obj->getHandle()); $this->handles[] = $obj; return $this; } public function clean() { foreach($this->handles as $obj) { curl_multi_remove_handle($this->handle, $obj->getHandle()); } return $this; } do { $status = curl_multi_exec($this->handle, $running); }while($running > 0); return $this; } public function getContent() { foreach ($this->handles as $obj) { $content[$obj->getUrl()] = curl_multi_getcontent($obj->getHandle()); } return $content; } }