1
我有json。這是考慮有關商家的信息完全id,鏈接。但是這個鏈接去重定向。就像這樣:從重定向獲取鏈接
http:\/\/partners.webmasterplan.com\/click.asp?ref=593856&site=5051&type=banner&tnb=1
我需要查看所有鏈接和鏈接,這將是最後的重定向我應該保存的鏈。什麼是更好的方式來做到這一點?技術,還是...? 你能給我一些建議嗎?謝謝!
我發現代碼可以幫助我嗎?
<?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";
?>
[我如何使用cURL獲取目標網址?](https://stackoverflow.com/questions/1439040/how-can-i-get-the-destination-url-using-curl) – CBroe