Skip to content

Instantly share code, notes, and snippets.

@enygma
Created October 1, 2014 19:58
Show Gist options
  • Save enygma/45253b0c9cf78a7f5aed to your computer and use it in GitHub Desktop.
Save enygma/45253b0c9cf78a7f5aed to your computer and use it in GitHub Desktop.
parallel with Guzzle
$url = '/wsapi/2.0/verify?'.http_build_query($params).'&h='.$signature;
// Make the connections in a pool
$pool = array();
$client = new \Guzzle\Http\Client();
foreach ($this->hosts as $host) {
$pool[] = $client->get('http://'.$host.$url);
}
$responses = $client->send($pool, array(
'complete' => function (\Guzzle\Http\Event\CompleteEvent $event) {
echo 'resp object: '.var_export($event->getResponse(), true)."\n";
$response = $event->getResponse()->getBody();
echo 'RESPONSE: '.$response."\n";
},
'error' => function(\Guzzle\Http\Event\ErrorEvent $event) {
echo 'Request failed: ' . $event->getRequest()->getUrl() . "\n";
echo $event->getException();
}
));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment