Necesito abrir una conexión con:
http://visionweb.occourts.org/Vision.../SearchCase.do
uso CURL pero... el sitio usa una cookie, sin esa cookie la búsqueda no devuelve resultados.
Tengo esto:
Código PHP:
extract($_POST);
//set POST variables
$url = 'http://visionweb.occourts.org/Vision_Public/SearchCase.do';
//<form name="caseInfoDisplayForm" method="post" action="/Vision_Public/DisplayCaseInfo.do">
$casenumber="06SM02800";
$fields = array(
'caseNbr'=>$casenumber,
'lastName'=>"",
'advSearch' =>"",
'middleName'=>"",
'enterpriseName'=>"",
'dln'=>"",
'firstName'=>"",
'dob_month'=>"",
'dob_day'=>"",
'dob_year'=>"",
'strictErrorChecking'=>"true"
);
//url-ify the data for the POST
foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
rtrim($fields_string,'&');
//open connection
$ch = curl_init();
$header[0] = "Accept: text/xml,application/xml,application/xhtml+xml,";
$header[0] .= "text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5";
$header[] = "Cache-Control: max-age=0";
$header[] = "Connection: keep-alive";
$header[] = "Keep-Alive: 300";
$header[] = "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7";
$header[] = "Accept-Language: en-us,en;q=0.5";
$header[] = "Pragma: ";
//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_USERAGENT, 'mozilla/5.0 (iphone; u; cpu like mac os x; en) applewebkit/420+ (khtml, like gecko) version/3.0 mobile/1c25 safari/419.3');
curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch,CURLOPT_POST,count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS,$fields_string);
curl_setopt($ch, CURLOPT_COOKIE, 'JSESSIONID=F73D02FB45D4F18DCD2D566E76D7D1C6');
// desguise referer
curl_setopt($ch, CURLOPT_REFERER, 'http://visionweb.occourts.org/Vision_Public/SearchCase.do');
//execute post
$result = curl_exec($ch);
//close connection
curl_close($ch);
//$text=curl($url);
echo $result;
Si espío la cookie en FF y pongo ese valor en este script entonces sí me trae el contenido.
Cómo puedo hacer ?
Ayuda por favor, muchas gracias.