sendAsync( $request, // This is the 'success' callback function($response) use ($i) { echo "$i -> " . $response->getStatus() . "\n"; }, // This is the 'error' callback. It is called for general connection // problems (such as not being able to connect to a host, dns errors, // etc.) and also cases where a response was returned, but it had a // status code of 400 or higher. function($error) use ($i) { if ($error['status'] === Client::STATUS_CURLERROR) { // Curl errors echo "$i -> curl error: " . $error['curl_errmsg'] . "\n"; } else { // HTTP errors echo "$i -> " . $error['response']->getStatus() . "\n"; } } ); } // After everything is done, we call 'wait'. This causes the client to wait for // all outstanding http requests to complete. $client->wait();