ahi la funcion
Código PHP:
function Conecta($data, $url, $tipo, $Cookie = "", $headers_array){
$post_str = '';
foreach($data as $key=>$val) {
$post_str .= $key.'='.urlencode($val).'&';
}
$post_str = substr($post_str, 0, -1);
$ch = curl_init();
if ($tipo == "POST"):
curl_setopt($ch, CURLOPT_URL, $url );
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_str);
curl_setopt($ch, CURLOPT_POST, count($data));
//curl_setopt($ch, CURLOPT_HEADER, TRUE);
//curl_setopt($ch, CURLOPT_HTTPHEADER, $headers_array);
//curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; es-ES; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13");
curl_setopt($ch, CURLOPT_REFERER, "http://laweb");
curl_setopt($ch, CURLOPT_COOKIE, $Cookie);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
endif;
if ($tipo == "GET"):
$url_get = $url. "" .$post_str;
curl_setopt($ch, CURLOPT_URL, $url_get);
curl_setopt($ch, CURLOPT_COOKIE, $Cookie);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
endif;
$llamada_pjud = curl_exec($ch );
$bytes_pjud = strlen($llamada_pjud);
curl_close($ch );
return array('llamada_pjud' => $llamada_pjud,
'bytes_pjud'=> $bytes_pjud,
'url' => $url. "" .$post_str,
'cookie' => $Cookie,
'post_str' => $post_str);
}
la respuesta que obtengo de llamada_pjud, es la mitad del codigo de la pagina a la que accedo via curl.