Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/297.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 获取重定向后的最终url_Php_Url - Fatal编程技术网

Php 获取重定向后的最终url

Php 获取重定向后的最终url,php,url,Php,Url,我在黑板上找到了类似的问题,但没有对我有用的答案 我的问题很简单 当(在我的浏览器中,chrome)转到此url时: 我将自动重定向到此url 我对使用php获取最终url的ID(最后一部分)感兴趣,因为它只有第一个链接 你知道怎么做吗 如果您从第一个url获取url参数并使用http而不是https(出于某种原因,它会重定向到http),请感谢 即 然后必须使用一些PHPs函数来检索URL(使用cURL/wget的file\u get\u contents、cURL扩展名或shell\u ex

我在黑板上找到了类似的问题,但没有对我有用的答案

我的问题很简单

当(在我的浏览器中,chrome)转到此url时:

我将自动重定向到此url

我对使用php获取最终url的ID(最后一部分)感兴趣,因为它只有第一个链接

你知道怎么做吗


如果您从第一个url获取url参数并使用http而不是https(出于某种原因,它会重定向到http),请感谢 即

然后必须使用一些PHPs函数来检索URL(使用cURL/wget的file\u get\u contents、cURL扩展名或shell\u exec)。 即


在这种特殊情况下,似乎是Flash在重写它。没有进行HTTP重定向。您将很难在PHP.hmmm中完成它。。谢谢事实上,我首先尝试了用Javascript编写,然后用document.getElementsByTagName('html')[0]检索源代码,显然我在PHP中没有得到相同的结果,我没有尝试过。。。我真丢脸!谢谢也许你知道为什么我在javascript中看不到这一点?
 https://w.soundcloud.com/player/?url=https%3a%2f%2fsoundcloud.com%2fdubz-cooker%2fdies-irae

becomes http://soundcloud.com/dubz-cooker/dies-irae
 <?php 
 $page = file_get_contents('http://soundcloud.com/dubz-cooker/dies-irae');
 preg_match('/"track_id"\:(\d+)/si', $page, $id);
 $id = $id[1];