Need help with sapo php script

Discussion in 'PHP' started by HentaiG, Mar 1, 2013.

  1. #1
    I'm currently fetching a dynamic link from sapo with a php curl script, I see some sites are doing this but they cache the link for 15 minutes so the script doesn't have to run every time someone plays a video, does anyone know how to do this?

    example sites: hentaistream.com and animestigma.com
     
    HentaiG, Mar 1, 2013 IP
  2. Darkfortune

    Darkfortune Greenhorn

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    11
    #2
    I should save the time you fetched it in a DB, if the time is greater than 15 minutes, save the time again and run the script.
     
    Darkfortune, Mar 1, 2013 IP
  3. HentaiG

    HentaiG Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #3
    Oh that's a good idea, can that be done in a php script? The script I have goes to sapo to fetch a link and takes about 1.5 seconds, would that lag if there's a lot of posts?
     
    HentaiG, Mar 1, 2013 IP
  4. Darkfortune

    Darkfortune Greenhorn

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    11
    #4
    I don't have any knowledge of sapo i'm sorry, but if it takes 1.5 seconds YES!
    In pure php its atleast 1/3 of that speed!

    I'm always using simpleHTMLdom to fetch website's, might want to take a look at it: http://simplehtmldom.sourceforge.net/
     
    Darkfortune, Mar 1, 2013 IP
  5. HentaiG

    HentaiG Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #5
    oh I got a caching script but I need a quick change in this code:

    <?php
    $fp = fopen($cachefile, 'w');
    fwrite($fp, ob_get_contents());
    fclose($fp);
    ob_end_flush();
    die();
    ?>

    see it writes to a cache file with a url inside but I need it to use the header function to automatically download from the url like this:
    header("Location: $url here");
     
    HentaiG, Mar 1, 2013 IP