Michael Dowling非常积极地维护狂饮是一个很好的方法。除了优雅的接口、异步调用和符合PSR,它还使REST调用的身份验证头非常简单:
// Create a client with a base URL
$client = new GuzzleHttp\Client(['base_url' => 'http://myservices.io']);
// Send a request to http://myservices.io/status with basic authentication
$response = $client->get('/status', ['auth' => ['username', 'password']]);