PHP使用CURL獲取302跳轉后的地址實例
來源:易賢網(wǎng) 閱讀:4464 次 日期:2014-09-18 14:41:15
溫馨提示:易賢網(wǎng)小編為您整理了“PHP使用CURL獲取302跳轉后的地址實例”,方便廣大網(wǎng)友查閱!

這篇文章主要介紹了PHP使用CURL獲取302跳轉后的地址實例,需要的朋友可以參考下

直接上代碼:

代碼如下:

/*返回一個302地址*/

function curl_post_302($url, $vars) {

$ch = curl_init();

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

curl_setopt($ch, CURLOPT_URL, $url);

curl_setopt($ch, CURLOPT_POST, 1);

curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); // 302 redirect

curl_setopt($ch, CURLOPT_POSTFIELDS, $vars);

$data = curl_exec($ch);

$Headers = curl_getinfo($ch);

curl_close($ch);

if ($data != $Headers)

return $Headers["url"];

else

return false;

}

上面的這個curl_post_302 函數(shù)可以直接取到302跳轉地址了.

更多信息請查看IT技術專欄

更多信息請查看網(wǎng)絡編程
易賢網(wǎng)手機網(wǎng)站地址:PHP使用CURL獲取302跳轉后的地址實例
關于我們 | 聯(lián)系我們 | 人才招聘 | 網(wǎng)站聲明 | 網(wǎng)站幫助 | 非正式的簡要咨詢 | 簡要咨詢須知 | 新媒體/短視頻平臺 | 手機站點

版權所有:易賢網(wǎng)