<?php $url = 'http://api.t.sina.com.cn/1410797647/statuses/9814935883'; function get302($url) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_TIMEOUT, 10); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_MAXREDIRS, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_exec($ch); $new_url = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL); curl_close($ch); return $new_url; } $new_url = get302($url); echo $new_url;