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_POST, TRUE);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_URL, $url );
curl_setopt($ch, CURLOPT_USERAGENT, "User-Agent: 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($con_post, CURLOPT_COOKIE, $Cookie);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_str);
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 );
$info = curl_getinfo($ch);
return array('llamada_pjud' => $llamada_pjud,
'bytes_pjud'=> $bytes_pjud,
'url' => $url. "" .$post_str,
'tiempo_total' => $info['total_time']);
}
$data = array();
$data['ROL_C'] = $_POST['ROL_C'];
$data['TIP_C'] = $_POST['TIP_C'];
$data['ERA_C'] = $_POST['ERA_C'];
$data['COD_T'] = $_POST['COD_T'];
$url = "URL";
$peticion = Conecta($data, $url, "GET", "", "");
echo "--------------------------------------------------------------------<br>";
echo "--------------------------------------------------------------------<br>";
echo "Return: " .$peticion['tiempo_total']. "<br>";
echo "Return: " .$peticion['bytes_pjud']. "<br>";
echo "--------------------------------------------------------------------<br>";