这是一个例子:
原始网址是http://www.vietbando.com/maps/#t=1&sk=258+lý+Thường+Kiệt
当我发布表格时。
它像这样更改为新的 URL
http://www.vietbando.com/maps/#t=1&sk=258+lý+Thường+Kiệt&l=4&kv=15.0132985,106.744091
如何获取新网址?
在这种情况下,您可以解析响应的标题以获取 url。您必须使用此代码来执行此操作:
$ch_url = curl_init();
curl_setopt($ch_url, CURLOPT_URL, 'http://www.example.com/)'; //your first url
curl_setopt($ch_url, CURLOPT_USERAGENT, 'AppleWebKit/530.5 (KHTML, like Gecko) Chrome/2.0.172.39 Safari/530.5');
curl_setopt($ch_url, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch_url, CURLOPT_HEADER, 1);
curl_setopt($ch_url, CURLOPT_NOBODY, 1); //we don't need to recieve the body of response
$headers = curl_exec($ch_url);
curl_close ($ch_url);
$pattern = '`.*?((http)://[\w#$&+,\/:;=?@.-]+)[^\w#$&+,\/:;=?@.-]*?`i'; //this regexp finds your url
if (preg_match_all($pattern,$headers,$matches))
$url = $matches[1][0]; //your second url