Wiem, że jest już założony praktycznie taki sam temat, ale nie dostałem na niego odpowiedzi. Problem nie jest zanadto złożony.
Jest sobie taka klasa/funkcja:
<?php
class Curl_Connection{
public function conn_cookie($str_http, $in_timeout, $bool_followlocation, $in_rtransfer, $str_cookies){
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $str_http);
curl_setopt($curl, CURLOPT_TIMEOUT, $in_timeout);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, $bool_followlocation);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, $in_rtransfer); //if '1' everything goes to var, '0' everything goes on screen
//curl_setopt($curl, CURLOPT_COOKIE, "puid=1234960049_00d9d6300949cdf13e90b98178b219d8EVv1; stsess=3af6f1385d62b5574091a396ea92c406v2; __utma=82371138.1252725828039137500.1234960051.1235165289.1235418356.5; __utmz=82371138.1234960051.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); __utmb=82371138.2.10.1235418356; __utmc=82371138");
curl_setopt($curl, CURLOPT_COOKIEFILE, 'cookies');
curl_setopt($curl, CURLOPT_COOKIEJAR, 'cookies');
$source=curl_exec($curl);
if (!$source)
throw new Exception('Connection failed or website does not exist!');
else{
return $source;
}
}
}
?>
To działa:
<?php
curl_setopt($curl, CURLOPT_COOKIE, "puid=1234960049_00d9d6300949cdf13e90b98178b219d8EVv1; stsess=3af6f1385d62b5574091a396ea92c406v2; __utma=82371138.1252725828039137500.1234960051.1235165289.1235418356.5; __utmz=82371138.1234960051.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); __utmb=82371138.2.10.1235418356; __utmc=82371138");
?>
A to:
<?php
curl_setopt($curl, CURLOPT_COOKIEFILE, 'cookies');
?>
ani to:
<?php
curl_setopt
($curl, CURLOPT_COOKIEJAR
, dirname(__FILE__).'/cookies');
?>
nie.
Wywołuje ją:
<?php
$conn = new Curl_Connection();
$source = $conn->conn_cookie("http://eventful.com/events?ga_type=events&ga_search=home&q=home", 10, true, 1, \"statycznie_wpisane_narazie\");
?>
Czemu i jaka może być przyczyna?
O dziwo
<?php
curl_setopt($curl, CURLOPT_COOKIEJAR, 'cookies');
?>
i tworzy plik w formacie Netscape. Czy przyczyną może być ten format?
Pozdrawiam.
Ten post edytował blackroger 23.02.2009, 23:33:58