Skip to content

Instantly share code, notes, and snippets.

@ronnyandre
Created August 14, 2013 11:39
Show Gist options
  • Save ronnyandre/6230278 to your computer and use it in GitHub Desktop.
Save ronnyandre/6230278 to your computer and use it in GitHub Desktop.
Simultaneously download websites using PHP and Guzzle
<?php
use Guzzle\Http\Client,
Guzzle\Common\Exception\MultiTransferException;
$client = new Client('http://graph.facebook.com');
try {
$responses = $client->send(array(
$client->get('/' . urlencode('http://tech.vg.no')),
$client->get('/' . urlencode('http://www.vg.no')),
));
foreach ($responses as $response) {
echo $response->getBody();
}
} catch (MultiTransferException $e) {
echo 'The following exceptions were encountered:' . PHP_EOL;
foreach ($e as $exception) {
echo $exception->getMessage() . PHP_EOL;
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment