ammusk354 Posted February 20, 2023 Posted February 20, 2023 I am trying to download a video with the URL using the curl function, I am getting an error while I do that. $file_url = "https://r7---sn-5hne6nse.googlevideo.com/videoplayback?nh=IgpwcjA0LmFtczE1KgkxMjcuMC4wLjE&dur=9506.899&signature=7AE59A98DC631F320F23928EB823EB8A42AFA3ED.DA59E710F432FCC58F083D8AC7D52F3A592F809A&initcwndbps=2113750&ei=aAUVWszAD5HW1wLBkrjwDw&lmt=1471404907996618&sparams=dur%2Cei%2Cid%2Cinitcwndbps%2Cip%2Cipbits%2Citag%2Clmt%2Cmime%2Cmm%2Cmn%2Cms%2Cmv%2Cnh%2Cpl%2Cratebypass%2Crequiressl%2Csource%2Cexpire&expire=1511348680&ms=au&id=o-ANUZv3t4OvJIXUC1ZiLxywIPvA9gtJOCH1fO5Yv_NaF6&mv=m&mt=1511326928&mn=sn-5hne6nse&pl=22&source=youtube&mm=31&requiressl=yes&ip=37.58.82.168&mime=video%2Fmp4&itag=22&ipbits=0&ratebypass=yes&key=yt6&title=PMI+-+ACP+Tutorial+Part+1+%7C+PMI+ACP+Exam+Tutorial+for+Beginners-1+%7C+PMI+Agile+Certification"; $upload_dir = realpath('public/uploads/contents/download/'); $name = uniqid(); $save_to = $upload_dir.'/'.$name.'.mp4'; $downloaded_file = fopen($save_to, 'w'); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $file_url); curl_setopt($ch, CURLOPT_FAILONERROR, true); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET'); curl_setopt($ch, CURLOPT_AUTOREFERER, true); curl_setopt($ch, CURLOPT_BINARYTRANSFER, true); curl_setopt($ch, CURLOPT_TIMEOUT, 10); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.0.3705; .NET CLR 1.1.4322)'); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_FILE, $downloaded_file); $page = curl_exec($ch); if (!$page) { echo "Error :- ".curl_error($ch); } curl_close($ch); I could download a PDF file using this code , but it doesn't for this video download .Any suggestion ??
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now