Ver Mensaje Individual
  #3 (permalink)  
Antiguo 31/05/2010, 03:16
Avatar de Nekeniehl
Nekeniehl
 
Fecha de Ingreso: julio-2009
Ubicación: Berlin, Alemania / Granada, España
Mensajes: 132
Antigüedad: 14 años, 10 meses
Puntos: 6
Respuesta: Recibir cookies con CURL

No sé si has trabajado antes con cUrl, pero te pongo un ejemplo tonto para que veas mas o menos un ejemplo y setear las opciones a tu gusto, este ejemplo checka si un server está on u off

Código PHP:
Ver original
  1. public static function checkServer (){
  2.         $domain = parent::$BMUrl;
  3.  
  4.         //init curl            
  5.         $curl=curl_init();
  6.        
  7.         //set curlopt
  8.         curl_setopt($curl,CURLOPT_URL, $domain);
  9.         curl_setopt($curl,CURLOPT_PORT, 443);
  10.         curl_setopt($curl,CURLOPT_NOBODY,true);
  11.         // dont verify ssl-cert
  12.         curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
  13.         curl_exec($curl);
  14.         $headers=curl_getinfo($curl);
  15.        
  16.         //close curl
  17.         curl_close($curl);
  18.         $str = "";
  19.         foreach($headers AS $k=>$v){
  20.             $str .= strtoupper($k).": ".$v."\r\n";
  21.         }
  22.         $msg=($headers['http_code']>= 200) && ($headers['http_code'] < 300)?"CheckServer::TRUE - Server returned\n\n".$str:"CheckServer::FALSE - Server returned\n\n".$str;
  23.         //returning values and saving a log response
  24.         if (($headers['http_code']>= 200) && ($headers['http_code'] < 300)){
  25.             genMsg(0,$msg, __FILE__, __FUNCTION__, __LINE__);
  26.             return true;
  27.         }
  28.         else if ($headers['http_code'] >= 300){
  29.                 genErrorMsg(1,$msg, __FILE__, __FUNCTION__, __LINE__);
  30.                 return false;
  31.         }
  32.         else{
  33.             genErrorMsg(2,$msg, __FILE__, __FUNCTION__, __LINE__);
  34.             return false;
  35.         }      
  36.     }
__________________
Antes de cambiar el mundo...dá tres vueltas por tu casa

Usa Google es tu amigo ;)