StyleGame

Online Tutorials

Va rog sa faceti cunoscut forumu. Cum puteti ajuta? De preferat la status pe yahoo messenger massuri etc. Va urez bafta in a ne ajuta cu respect echipa stylegame

    [PHP] Simple cURL example

    Distribuiţi
    avatar
    CYobY
    Administrator
    Administrator

    Mesaje : 197
    Data de inscriere : 04/10/2009
    Varsta : 24
    Localizare : VASLUI

    [PHP] Simple cURL example

    Mesaj Scris de CYobY la data de Sam Oct 24, 2009 6:26 pm

    Cod:
        function DownloadUrl($Url){

            // is curl installed?
            if (!function_exists('curl_init')){
                die('CURL is not installed!');
            }

            // create a new curl resource
            $ch = curl_init();

            /*
            Here you find more options for curl:
            http://www.php.net/curl_setopt
            */

            // set URL to download
            curl_setopt($ch, CURLOPT_URL, $Url);

            // set referer:
            curl_setopt($ch, CURLOPT_REFERER, "http://www.google.com/");

            // user agent:
            curl_setopt($ch, CURLOPT_USERAGENT, "MozillaXYZ/1.0");

            // remove header? 0 = yes, 1 = no
            curl_setopt($ch, CURLOPT_HEADER, 0);

            // should curl return or print the data? true = return, false = print
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

            // timeout in seconds
            curl_setopt($ch, CURLOPT_TIMEOUT, 10);

            // download the given URL, and return output
            $output = curl_exec($ch);

            // close the curl resource, and free system resources
            curl_close($ch);

            // print output
            return $output;
        }


    _________________
    RESPECT

      Acum este: Mar Sept 25, 2018 8:50 pm