Разделы
Veselov CV | vvShop © 2008 – 2018
Контакты
email: igor@veselov.sumy.ua
skype: utz0r2
Вернуться
» » » Guzzle - PHP HTTP client

Guzzle - PHP HTTP client


$client = new GuzzleHttp\Client();
$res = $client->get('https://api.github.com/user', ['auth' =>  ['user', 'pass']]);
echo $res->getStatusCode();
// "200"
echo $res->getHeader('content-type');
// 'application/json; charset=utf8'
echo $res->getBody();
// {"type":"User"...'

// Send an asynchronous request.
$request = new \GuzzleHttp\Psr7\Request('GET', 'http://httpbin.org');
$promise = $client->sendAsync($request)->then(function ($response) {
    echo 'I completed! ' . $response->getBody();
});
$promise->wait();

http://guzzle.readthedocs.org/en/latest/
Оставить комментарий
Вверх