#104 GuzzleHttp requests examples
state: open opened by: adrianharabula on: 5/20/2017
The sync version
$client = new \GuzzleHttp\Client();
$request = $client->get('https://webhooks.condr.me/version');
$message = $request->getBody();
The Async version
$client = new \GuzzleHttp\Client();
$promise = $client->getAsync('https://webhooks.condr.me/version');
$promise->then(
function (ResponseInterface $res) {
$msg = (string) $res->getBody();
\Debugbar::notice(msg);
},
function (RequestException $e) {
echo $e->getMessage() . "\n";
echo $e->getRequest()->getMethod();
}
);
Comments
from: adrianharabula on: 6/6/2017
maybe add this to documentation