dimanche 1 août 2021

file_get_contents($url): failed to open stream: HTTP request failed! HTTP/1.1 401

Trying something like

$url = $this->getValue($item, ['manufacturingReadyDataUrl'], null);
$file = file_get_contents($url);
Storage::put('file.pdf', $file);

In Laravel. But failed to get and download the file.

The URL require GET method.

Encounter message:

file_get_contents($url): failed to open stream: HTTP request failed! HTTP/1.1 401 Unauthorized

The reason for this is because it require Bearer token.

Trying to find similar implementation on Laravel, but always found how to implement passport, create a download function, but not how to download file from link that require bearer token.

Any idea how?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire