0

I have this kind of url

http://www.shareasale.com/r.cfm?u=552661&b=558522&m=51248&afftrack=&urllink=www%2Eericdress%2Ecom

But when I use curl it gives original url as a final redirect URL.

currently I am using below code

$options = array(
        CURLOPT_RETURNTRANSFER => true, // return web page
        CURLOPT_HEADER => true, // return headers
        CURLOPT_FOLLOWLOCATION => true, // follow redirects
        CURLOPT_ENCODING => "", // handle all encodings
        CURLOPT_USERAGENT => "spider", // who am i
        CURLOPT_AUTOREFERER => true, // set referer on redirect
        CURLOPT_CONNECTTIMEOUT => 120, // timeout on connect
        CURLOPT_TIMEOUT => 120, // timeout on response
        CURLOPT_MAXREDIRS => 10, // stop after 10 redirects
    );
    $ch = curl_init($url);
    curl_setopt_array($ch, $options);
    $content = curl_exec($ch);
    $err = curl_errno($ch);
    $errmsg = curl_error($ch);
    $header = curl_getinfo($ch);
    curl_close($ch);
    return $header['url'];
user1482873
  • 11
  • 1
  • 3

0 Answers0