如何在php中获取url重定向
就像你在浏览器中填写一样
--- https://lh3.googleusercontent.com/1I1FrmTThL6inx681XYApSPq5wrixuVzVvRZPiTHsiA=m22---
成为
--- // r2---sn-i3b7kn7z.googlevideo.com/videoplayback?id=d8c2e2b465cd28a7&itag=22&source=picasa&begin=0&requiressl=yes&mm=30&mn=sn- i3b7kn7z&安培; MS = NXU&安培; MV = M&安培; NH = IgpwcjAxLmhrZzA4KgkxMjcuMC4wLjE&安培; PL = 19安培; MIME =视频/ MP4&安培; LMT = 1438597716404239&安培; MT = 1448012195&安培; IP = 14.162.103.141&安培; ipbits = 8&安培;到期= 1448041095&安培; sparams = IP ,ipbits,到期,ID,ITAG,来源,requiressl,毫米,MN,MS,MV,NH,PL,MIME,LMT&安培;签名= 06D26A3C592DD99A4E7E2BC04747E3022AD30071.09139E1F57105925D9BF39F6BE152E7068350D40&安培;键= CK2 ---
我尝试使用代码
<?php
$ch = curl_init("//lh3.googleusercontent.com/gNqSDOMdfLcZDOv1j7TGfEQSzXrk0ngBSloMd6JSjGQ=m22");
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_NOBODY, true);
$response = curl_exec($ch);
$resolved = curl_getinfo($ch);
echo $resolved['url'];
?>
://r8---sn-ab5l6nel.googlevideo.com/videoplayback ID = f091f46ecaa177ea&安培; ITAG = 22&安培;源= Picasa和安培;开始= 0&安培; requiressl = YES&安培;毫米= 30&安培; MN = SN-ab5l6nel&安培; MS = NXU&安培; MV = U&安培; PL = 48&安培; MIME =视频/ MP4&安培; LMT = 1438598135161434&安培; MT = 1448012329&安培; IP = 2604:A880:800:A1 :: 75:6001&安培; ipbits = 48&安培;到期= 1448042024&安培; sparams = IP,ipbits,到期,ID,ITAG,来源,requiressl,毫米,MN,MS,MV,PL,MIME,LMT&安培;签名= 9259AF5059FA660980BB65F95637C73690207B67.3F352385B6D53E5FF4938A859338554D90173F7A&安培;键= CK2
我很高兴,但它没有运行。
非常感谢!
答案 0 :(得分:0)
我知道您要执行的操作并且视频无法播放,因为您收到的响应不会包含Access-Control-Origin-Policy
标头。这意味着浏览器无法访问没有该标头的响应接收。这是出于安全目的。如果要解决此问题,您必须将https://r2---sn-i3b7kn7z
部分替换为https://redirector
。