how to use to curl to follow a redirect after x amount of time

Discussion in 'PHP' started by Vyliss, Aug 30, 2008.

  1. #1
    Well, I'm trying to submit a form on a website but after submission, the form takes you to a page that redirects to another page after a certain amount of time. Curl catches the redirection page but how do I get it to wait and stay until it redirects to the new page, so I can retrieve the data on that page?

    Help would be greatly appreciated, thanks!
     
    Vyliss, Aug 30, 2008 IP
  2. matthewrobertbell

    matthewrobertbell Peon

    Messages:
    781
    Likes Received:
    35
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I think you'd have to do your first curl request (with following off), read the header, get the url from the header, sleep() for however long, then do another request.
     
    matthewrobertbell, Aug 31, 2008 IP
  3. octalsystems

    octalsystems Well-Known Member

    Messages:
    352
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    135
    Digital Goods:
    1
    #3
    u have to put a prefined timout in the curl and after that u can put the regex on the output if the output is not in the normal format expected then the script is timed out and u can take the steps according to that
     
    octalsystems, Aug 31, 2008 IP
  4. matthewrobertbell

    matthewrobertbell Peon

    Messages:
    781
    Likes Received:
    35
    Best Answers:
    0
    Trophy Points:
    0
    #4
    That's not right, it will be willing to wait however many seconds before timing out, but it will still redirect instantly.
     
    matthewrobertbell, Aug 31, 2008 IP
  5. Vyliss

    Vyliss Peon

    Messages:
    43
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Well does anyone have actual code they could show me as an example? ^^ That would help a lot thanks
     
    Vyliss, Sep 7, 2008 IP