I would like to use the invoiz api to download an invoice: https://app.invoiz.de/api/documentation/#/invoices/download%20InvoiceDocument
my code:
// DOWNLOAD INVOICES
$curl = curl_init('https://app.invoiz.de/api/invoice/ID_OF_INVOICE/download');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($curl, CURLOPT_USERPWD, $apiKey . ":" . $secretApiKey);
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
'Authorization: Bearer '.$token->token,
'accept: application/pdf'
));
$content = curl_exec($curl);
curl_close($curl);
echo $content shows:
But I would like to download the pdf file. How can I realize it?
CURL response:
access-control-allow-origin: *
connection: keep-alive
content-disposition: attachment; filename="MyFileName.pdf" content-type: application/pdf
date: Tue,31 Jan 2023 10:50:24 GMT
strict-transport-security: max-age=7776000; includeSubDomains; preload
transfer-encoding: chunked