MENU

php获取302跳转地址

January 17, 2020 • php

function  curl_post_302($url)
{
    $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
    $data = curl_exec($ch);
    $Headers =  curl_getinfo($ch);
    curl_close($ch);
    if ($data != $Headers)
        return  $Headers["url"];
    else
        return false;
}
转载请注明出处,并添加原文地址

Archives QR Code Tip
QR Code for this page
Tipping QR Code