【发布时间】:2018-12-15 14:24:10
【问题描述】:
当我使用GuzzleHttp 并发送请求时,我的laravel 程序被中断,我将停止服务器并再次运行它。如果使用在线 API 或仅使用没有端口号的 localhost,则没有问题并且可以正常工作。但是当使用端口 8000 或任何端口时,Laravel 应用程序会挂断。
我的代码是
$http = new \GuzzleHttp\Client;
$response = $http->post('http://localhost:8000/oauth/token', [
'form_params' => [
'grant_type' => 'password',
'client_id' => 2,
'client_secret' => 'AXXwkDGiuEewwd1tza4haWrz6Gku0LRGgLIaayxC',
'username' => 'saeed',
'password' => '12345678',
]
]);
return json_decode((string)$response->getBody(), true);
【问题讨论】: