📅  最后修改于: 2022-03-11 14:53:54.403000             🧑  作者: Mango
$response = $client->request('GET', 'https://...');
// gets the HTTP status code of the response
$statusCode = $response->getStatusCode();
// gets the HTTP headers as string[][] with the header names lower-cased
$headers = $response->getHeaders();
// gets the response body as a string
$content = $response->getContent();
// casts the response JSON content to a PHP array
$content = $response->toArray();
// casts the response content to a PHP stream resource
$content = $response->toStream();
// cancels the request/response
$response->cancel();
// returns info coming from the transport layer, such as "response_headers",
// "redirect_count", "start_time", "redirect_url", etc.
$httpInfo = $response->getInfo();
// you can get individual info too
$startTime = $response->getInfo('start_time');
// e.g. this returns the final response URL (resolving redirections if needed)
$url = $response->getInfo('url');
// returns detailed logs about the requests and responses of the HTTP transaction
$httpLogs = $response->getInfo('debug');