want to be able to use another site in the background to get stuff

Discussion in 'PHP' started by quadiator, Jul 20, 2007.

  1. #1
    hi,

    i am starting to build a site, i want to be able to use another site in the background to do a function. there is this site that takes in any megaupload link and changes that into a premium link. is there a way for me to use that site in the background, ie if i a user paste's the link in my site, can i use that other site in the background to paste the link there and grab the premium link? is that possible with php? if so how complicated will the script be?
     
    quadiator, Jul 20, 2007 IP
  2. Greg Carnegie

    Greg Carnegie Peon

    Messages:
    385
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    0
    #2
    How complex will it be to get premium link depends on site from which you want to grab this link.

    You can do this with AJAX+PHP, or just PHP

    You didn't wrote much details, but structure will be similar to this:
    <?php
    $fp = fsockopen("www.example.com", 80, $errno, $errstr, 30);
    if (!$fp) {
        echo "$errstr ($errno)<br />\n";
    } else {
        $out = "GET / HTTP/1.1\r\n";
        $out .= "Host: www.example.com\r\n";
        $out .= "Connection: Close\r\n\r\n";
    
        fwrite($fp, $out);
        while (!feof($fp)) {
            echo fgets($fp, 128);
        }
        fclose($fp);
    }
    ?> 
    PHP:
    It is much easier to do with cURL library for PHP if you have it installed.

    Anyway using code i gave you you can download data from site with premium links and using regular expressions you need search this data to find where they are and how they look like.
     
    Greg Carnegie, Jul 20, 2007 IP