php curl超长url格式不正确

编程入门 行业动态 更新时间:2024-10-10 00:24:43
本文介绍了php curl超长url格式不正确的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个长的网址嵌套在一个变量:$ mp4,并试图下载它与curl,但我得到格式错误。

I have a long url nested in a variable: $mp4, and trying to download it with curl but i'm getting malformed error. Please help me if you can, thank you in advance!

以下是我在我的php脚本中:

The below is what I have in my php script:

exec("curl -o $fnctid.mp4 \"$mp4\"");

错误讯息:

curl: (3) <url> malformed

测试下载的示例网址:

f26.stream.nixcdn/6f4df1d8c248cf149b846c24d32f1c35/514e0209/PreNCT5/22-TaylorSwift-2426783.mp4

推荐答案

当前网址正在返回 408 - Request Timeout 你就是这个简单的代码:

The current url is returning 408 - Request Timeout if that is fixed you are you this simple code :

$url = 'f26.stream.nixcdn/6f4df1d8c248cf149b846c24d32f1c35/514e0209/PreNCT5/22-TaylorSwift-2426783.mp4'; $useragent = 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/533.2 (KHTML, like Gecko) Chrome/5.0.342.3 Safari/533.2'; $file = __DIR__ . DIRECTORY_SEPARATOR . basename($url); $fp = fopen($file, 'w+'); $ch = curl_init($url); curl_setopt($ch, CURLOPT_TIMEOUT, 320); curl_setopt($ch, CURLOPT_FILE, $fp); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_USERAGENT, $useragent); echo curl_exec($ch); var_dump(curl_getinfo($ch)); // return request information curl_close($ch); fclose($fp);

更多推荐

php curl超长url格式不正确

本文发布于:2023-11-02 07:14:44,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1551717.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:不正确   格式   php   curl   url

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!