0

I am writing a function which download Zoom Meeting Recording (mp4 file). Using file_get_contents($url) and file_put_contents to save the file, it was throwing error - 403 forbidden.

But when I do it using axios, it download and saves the file properly. Here is the working code -

axios({
    method: "GET",
    url: url,
    responseType: "stream"
}).then(function (response) {
    response.data.pipe(fs.createWriteStream("test.mp4"));
})

I tried copy(), file_get_contents(), fopen() and also tried setting context and ini following answers to this question but all returning forbidden though the same URL works in axios.

IMSoP
  • 89,526
  • 13
  • 117
  • 169

1 Answers1

0

I was able to do it using Guzzle. I'm not sure why (appreciated if someone can explain) but here is the way if someone is looking for a solution -

$client = new GuzzleHttp\Client();
$request = new GuzzleHttp\Psr7\Request('GET', $url);
$res = $client->sendAsync($request)->wait();
file_put_contents('test.mp4', $res->getBody());