相关疑难解决方法(0)

php从源URL获取重定向的url

我有这个链接:

http://libero-news.it.feedsportal.com/c/34068/f/618095/s/2e34796f/l/0L0Sliberoquotidiano0Bit0Cnews0C12735670CI0Esaggi0Eper0Ele0Eriforme0Ecostituzionali0EChiaccherano0Ee0Eascoltano0Bhtml/story01.htm

如果你访问它,这将成为:

http://www.liberoquotidiano.it/news/1273567/I-saggi-per-le-riforme-costituzionali-Chiaccherano-e-ascoltano.html

如何从第一个链接获取第二个链接?

我试过这个但是没有用,给我的第一个链接回复:

<?php
$url="http://libero-news.it.feedsportal.com/c/34068/f/618095/s/2e34796f/l/0L0Sliberoquotidiano0Bit0Cnews0C12735670CI0Esaggi0Eper0Ele0Eriforme0Ecostituzionali0EChiaccherano0Ee0Eascoltano0Bhtml/story01.htm";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$a = curl_exec($ch);
print_r($a);echo"<br>";
if(preg_match('#Location: (.*)#', $a, $r)){
 $l = trim($r[1]);
 echo $l;
 }else echo "not working";
 ?>
Run Code Online (Sandbox Code Playgroud)

非常感谢.

php redirect url-rewriting url-redirection

20
推荐指数
3
解决办法
4万
查看次数

PHP-使用网址获取文件大小

我正试图从远程URL获取图像的文件大小,我正试图像这样:

$remoteUrl = $file->guid;
//remote url example: http://myApp/wp-content/uploads/2017/05/Screen-Shot-2017-05-08-at-10.35.54.png  

$fileSize = filesize($remoteUrl);
Run Code Online (Sandbox Code Playgroud)

但是,我得到:

filesize():http://myApp/wp-content/uploads/2017/05/Screen-Shot-2017-05-08-at-10.35.54.png的统计信息失败

php laravel

4
推荐指数
2
解决办法
1635
查看次数

标签 统计

php ×2

laravel ×1

redirect ×1

url-redirection ×1

url-rewriting ×1