Nije cURL tako tezak. Pogledaj nekoliko primera. Posto tebi treba statistika za tvoj bend, u slucaju da je potrebno da si ulogovan, moras koristiti i kolacice... bas kao pravi browser.
Evo extra prostog primera sa http://www.php.net/manual/en/function.curl-exec.php
<?php
// create a new cURL resource
$ch = curl_init();
// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, "http://www.example.com/");
curl_setopt($ch, CURLOPT_HEADER, 0);
// grab URL and pass it to the browser
curl_exec($ch);
// close cURL resource, and free up system resources
curl_close($ch);
?>
Dopuna: 18 Feb 2009 23:36
Ovo je deo jednog mog koda, tu mozes da vidis kako koristiti kolacice ako ti zatreba.
$cookie je putanje do txt fajla koji cuva kolacice.
...
curl_setopt($this->ch, CURLOPT_URL, $url); //sets url
curl_setopt($this->ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6");
curl_setopt($this->ch, CURLOPT_FAILONERROR, 0); //even if there is error it will return string
curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, 1); //return page as string
curl_setopt($this->ch, CURLOPT_HEADER, 1); //header
curl_setopt($this->ch, CURLOPT_COOKIEFILE, $cookie);
curl_setopt($this->ch, CURLOPT_COOKIEJAR, $cookie);
$string1=curl_exec($this->ch); //executes curl
$this->str1=$string1;
$err=curl_error($this->ch);
...
|