Ver Mensaje Individual
  #10 (permalink)  
Antiguo 11/07/2008, 10:18
Avatar de Panino5001
Panino5001
Me alejo de Omelas
 
Fecha de Ingreso: mayo-2004
Ubicación: -34.637167,-58.462984
Mensajes: 5.148
Antigüedad: 22 años, 5 meses
Puntos: 834
Respuesta: CURL tomar y enviar una cookie

Probá así:
Código PHP:
<?php
$location 
= "";
$cookiearr = array();
function 
getPage($numero)
{
  global 
$location;
  global 
$cookiearr;
  global 
$ch;
    
$ch = curl_init();
    
curl_setopt($ch, CURLOPT_URL,"http://visionweb.occourts.org/Vision_Public/SearchCase.do");
    
curl_setopt($ch, CURLOPT_REFERER, "");
    
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    
curl_setopt($ch, CURLOPT_HEADERFUNCTION, 'read_header');
      
$html = curl_exec($ch);
    
$matches = array();
    
    
    
$fields = array(
                        
'caseNbr'=>$numero,
                        
'lastName'=>"",
                         
'advSearch' =>"",
                         
'middleName'=>"",
                         
'enterpriseName'=>"",
                         
'dln'=>"",
                         
'firstName'=>"",
                         
'dob_month'=>"",
                         
'dob_day'=>"",
                         
'dob_year'=>"",
                         
'action'=>"Search"
                
);


foreach(
$fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
$fields_string=substr(trim($fields_string),0,-1);

    
$action = "http://visionweb.occourts.org/Vision_Public/SearchCase.do";
    
curl_setopt($ch, CURLOPT_URL,$action);
    
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
    
curl_setopt($ch, CURLOPT_POST, 1);
    
curl_setopt($ch, CURLOPT_POSTFIELDS,$fields_string);

    
$html = curl_exec($ch);

  
curl_setopt($ch, CURLOPT_URL, "http://visionweb.occourts.org/Vision_Public/SearchCase.do");
  
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);

    
$html = curl_exec($ch);

  

    return 
$html;
}

function 
read_header($ch, $string)
{
    global 
$location;
    global 
$cookiearr;
    global 
$ch;
    
    
$length = strlen($string);
    if(!
strncmp($string, "Location:", 9))
    {
      
$location = trim(substr($string, 9, -1));
    }
    if(!
strncmp($string, "Set-Cookie:", 11))
    {
      
$cookiestr = trim(substr($string, 11, -1));
      
$cookie = explode(';', $cookiestr);
      
$cookie = explode('=', $cookie[0]);
      
$cookiename = trim(array_shift($cookie)); 
      
$cookiearr[$cookiename] = trim(implode('=', $cookie));
    }
    
$cookie = "";
    if(
trim($string) == "") 
    {
      foreach (
$cookiearr as $key=>$value)
      {
        
$cookie .= "$key=$value; ";
      }
      
curl_setopt($ch, CURLOPT_COOKIE, $cookie);
    }

    return 
$length;
}
echo 
getPage('06SM02800');
?>
Es más o menos lo mismo, pero tenías un nombre de campo mal colocado.