Created
October 1, 2014 19:58
-
-
Save enygma/45253b0c9cf78a7f5aed to your computer and use it in GitHub Desktop.
parallel with Guzzle
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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