环境:Laravel 5.6
安装 composer require guzzlehttp/guzzle
vendor\guzzlehttp\guzzle
官方例子
$client = new GuzzleHttp\Client(); $res = $client->request('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();
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/zlb25246/article/details/80368789
发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/113126.html原文链接:https://javaforall.net