Symfony Get Api Data

[Solved] Symfony Get Api Data | Php Frameworks Symfony - Code Explorer | yomemimo.com
Question : symfony get api data

Answered by : inquisitive-impala-zhewz8mp98xc

$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');

Source : https://symfony.com/doc/current/http_client.html | Last Update : Wed, 24 Nov 21

Answers related to symfony get api data

Code Explorer Popular Question For Php Frameworks Symfony