Skip to content

Instantly share code, notes, and snippets.

@shin1x1
Created July 25, 2014 01:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shin1x1/15ba58ae79449b8a5587 to your computer and use it in GitHub Desktop.
Save shin1x1/15ba58ae79449b8a5587 to your computer and use it in GitHub Desktop.
guzzle3_send_event_listener_sample
<?php
use Guzzle\Http\Client;
use Guzzle\Http\Curl\CurlMultiInterface;
use Symfony\Component\EventDispatcher\Event;
require_once __DIR__ . '/vendor/autoload.php';
$client = new Client();
$client->getEventDispatcher()->addListener(CurlMultiInterface::MULTI_EXCEPTION, function(Event $e) {
throw new Exception();
});
$curlMulti = $client->getCurlMulti();
$curlMulti->setEventDispatcher($client->getEventDispatcher());
$client->setCurlMulti($curlMulti);
$client->send(array(
$client->get('http://example.com/a'),
$client->get('http://example.com/b'),
$client->get('http://example.com/c'),
));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment