cURL question, how to return final URL where Im redirected?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mikhail Kovalev

    cURL question, how to return final URL where Im redirected?

    I'm sending a html form with cURL to some file.php which does
    something with the sent data and at the end redirects me to some other
    URL, which is different every time, something like this:

    $ch = curl_init();
    curl_setopt($cu rl, CURLOPT_FOLLOWL OCATION, true);
    curl_setopt($cu rl, CURLOPT_RETURNT RANSFER, true);
    ....
    $result = curl_exec($ch);

    $result here is a string of the resulting page at the end

    I need to return the final URL of where I have been redirected when
    sending the request

    anyone has an idea?=)
    thanks

  • Captain Paralytic

    #2
    Re: cURL question, how to return final URL where Im redirected?

    On 13 Jul, 12:45, Mikhail Kovalev <mikhail_kova.. .@mail.ruwrote:
    I'm sending a html form with cURL to some file.php which does
    something with the sent data and at the end redirects me to some other
    URL, which is different every time, something like this:
    >
    $ch = curl_init();
    curl_setopt($cu rl, CURLOPT_FOLLOWL OCATION, true);
    curl_setopt($cu rl, CURLOPT_RETURNT RANSFER, true);
    ...
    $result = curl_exec($ch);
    >
    $result here is a string of the resulting page at the end
    >
    I need to return the final URL of where I have been redirected when
    sending the request
    >
    anyone has an idea?=)
    thanks
    Where do you need to return it to, the site that sent it?

    Comment

    • Andy Hassall

      #3
      Re: cURL question, how to return final URL where Im redirected?

      On Fri, 13 Jul 2007 04:45:27 -0700, Mikhail Kovalev <mikhail_kovale v@mail.ru>
      wrote:
      >I'm sending a html form with cURL to some file.php which does
      >something with the sent data and at the end redirects me to some other
      >URL, which is different every time, something like this:
      >
      >$ch = curl_init();
      >curl_setopt($c url, CURLOPT_FOLLOWL OCATION, true);
      >curl_setopt($c url, CURLOPT_RETURNT RANSFER, true);
      >...
      >$result = curl_exec($ch);
      >
      >$result here is a string of the resulting page at the end
      >
      >I need to return the final URL of where I have been redirected when
      >sending the request


      CURLINFO_EFFECT IVE_URL ?

      Or you could set CURLOPT_HEADERF UNCTION and read the Location headers on the
      redirect(s).

      --
      Andy Hassall :: andy@andyh.co.u k :: http://www.andyh.co.uk
      http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool

      Comment

      • Mikhail Kovalev

        #4
        Re: cURL question, how to return final URL where Im redirected?

        Thanks it nailed it


        On 13 Jul, 14:21, Andy Hassall <a...@andyh.co. ukwrote:
        On Fri, 13 Jul 2007 04:45:27 -0700, Mikhail Kovalev <mikhail_kova.. .@mail.ru>
        wrote:
        >
        I'm sending a html form with cURL to some file.php which does
        something with the sent data and at the end redirects me to some other
        URL, which is different every time, something like this:
        >
        $ch = curl_init();
        curl_setopt($cu rl, CURLOPT_FOLLOWL OCATION, true);
        curl_setopt($cu rl, CURLOPT_RETURNT RANSFER, true);
        ...
        $result = curl_exec($ch);
        >
        $result here is a string of the resulting page at the end
        >
        I need to return the final URL of where I have been redirected when
        sending the request
        >

        >
        CURLINFO_EFFECT IVE_URL ?
        >
        Or you could set CURLOPT_HEADERF UNCTION and read the Location headers on the
        redirect(s).
        >
        --
        Andy Hassall :: a...@andyh.co.u k ::http://www.andyh.co.ukhttp://www.and....co.uk/space:: disk and FTP usage analysis tool

        Comment

        Working...