Ver Mensaje Individual
  #5 (permalink)  
Antiguo 16/01/2013, 09:07
onda_allstar
 
Fecha de Ingreso: enero-2007
Mensajes: 17
Antigüedad: 17 años, 2 meses
Puntos: 0
Respuesta: CURL error al descargar CSV

He conseguido que me funcione en local, pero al probarlo en el servidor web no me funciona, me sigue devolviendo un error cómo si no estuviera logeado. Revisaré los parametros del servidor haber si encuentro el error.

Aquí está el codigo:

Código PHP:
    file_put_contents('cookie.txt''');
    
$url "http://www.web.com/login"
    
$url2 "www.web.com/dat.CSV";
    
    
$username "user"
    
$password "password";             
    
    
$fields = array("Email" => $username"Passwd" => $password);  
    foreach(
$fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
    
$fields_string substr(trim($fields_string),0,-1);
 
    
$ch curl_init();
    
curl_setopt($chCURLOPT_URL$url);
    
curl_setopt($chCURLOPT_SSL_VERIFYPEER0);
    
curl_setopt($chCURLOPT_FOLLOWLOCATION1);
    
curl_setopt($chCURLOPT_RETURNTRANSFER1);
    
curl_setopt($chCURLOPT_POST1);
    
curl_setopt($chCURLOPT_COOKIEJAR"cookie.txt");
    
curl_setopt($chCURLOPT_COOKIEFILE"cookie.txt");
    
curl_setopt($chCURLOPT_POSTFIELDS$fields_string);
 
    
$html curl_exec($ch);

    
curl_setopt($chCURLOPT_URL$url2);
    
curl_setopt($chCURLOPT_COOKIEFILE"cookie.txt");
    
curl_setopt($chCURLOPT_RETURNTRANSFER1);
 
    
$html curl_exec($ch);
 
    echo 
$html