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: 19 años, 10 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($chCURLOPT_URL,"http://visionweb.occourts.org/Vision_Public/SearchCase.do");
    
curl_setopt($chCURLOPT_REFERER"");
    
curl_setopt($chCURLOPT_SSL_VERIFYPEER0);
    
curl_setopt($chCURLOPT_RETURNTRANSFER1);
    
curl_setopt($chCURLOPT_FOLLOWLOCATION1);
    
curl_setopt($chCURLOPT_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($chCURLOPT_URL,$action);
    
curl_setopt($chCURLOPT_RETURNTRANSFER,1);
    
curl_setopt($chCURLOPT_POST1);
    
curl_setopt($chCURLOPT_POSTFIELDS,$fields_string);

    
$html curl_exec($ch);

  
curl_setopt($chCURLOPT_URL"http://visionweb.occourts.org/Vision_Public/SearchCase.do");
  
curl_setopt($chCURLOPT_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($string9, -1));
    }
    if(!
strncmp($string"Set-Cookie:"11))
    {
      
$cookiestr trim(substr($string11, -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($chCURLOPT_COOKIE$cookie);
    }

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