Axios ResponseType流的PHP版本
我正在编写下载Zoom Meeting Recording(MP4文件)的功能。使用file_get_contents($ url)和file_put_contents来保存文件,它抛出了错误-403禁止。
但是,当我使用Axios进行操作时,它会正确下载并保存文件。这是工作代码 -
axios({
method: "GET",
url: url,
responseType: "stream"
}).then(function (response) {
response.data.pipe(fs.createWriteStream("test.mp4"));
})
我尝试了copy(),file_get_contents(),fopen(),并且还尝试了设置上下文和INI以下答案这个问题,但所有返回的返回,尽管相同的URL在Axios中起作用。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我能够使用guzzle做到这一点。我不确定为什么(感谢某人可以解释),但是如果有人正在寻找解决方案 -
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 -