Example #1
0
 * Custom Response class
 */
class CustomResponse extends Curl\Response\PlainResponse
{
    /**
     * (non-PHPdoc)
     * @see Curl.Response::hasError()
     */
    public function hasError()
    {
        return parent::hasError() && 200 != $this->getInfo(true)->http_code;
    }
}
// use custom response class
// it must implement the Curl\IResponse interface
$request->setResponseClass('CustomResponse');
var_dump($request->send()->hasError());
// set response type
/* @var $response Curl\Response\XMLResponse */
$response = $request->setResponseType('xml')->send();
var_dump($response, $response->toArray());
// use curl_multi
$executor = new Curl\MultiExecutor();
// define a number of concurrent requests
$executor->setConcurrentRequestsLimit(2);
// set common options to all requests
$executor->setCommonRequestOptions(array(CURLOPT_AUTOREFERER => 1, 'headers' => array(), Curl\Request::EVENT_BEFORE_SEND => function () {
    /* do something */
}));
// NOTE: it's important to define common options BEFORE call Curl\MultiExecutor::addRequest()
for ($i = 0; $i < 10; $i++) {