Ver Mensaje Individual
  #3 (permalink)  
Antiguo 23/03/2009, 07:53
miguelaniez
 
Fecha de Ingreso: octubre-2008
Mensajes: 44
Antigüedad: 15 años, 6 meses
Puntos: 1
Ok muchas gracias

Estoy encontrando problemas para hacerlo en una pagina que usa zencart, estoy usando esta clase

Código PHP:
class cURL {
    var 
$headers;
    var 
$user_agent;
    var 
$compression;
    var 
$cookie_file;
    var 
$proxy;
    function 
cURL($cookies=TRUE,$cookie='cookies.txt',$compression='gzip',$proxy='') {
        
$this->headers[] = 'Accept: image/gif, image/x-bitmap, image/jpeg, image/pjpeg';
        
$this->headers[] = 'Connection: Keep-Alive';
        
$this->headers[] = 'Content-type: application/x-www-form-urlencoded;charset=iso-8859-1';
        
$this->user_agent 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.0.3705; .NET CLR 1.1.4322; Media Center PC 4.0)';
        
$this->compression=$compression;
        
$this->proxy=$proxy;
        
$this->cookies=$cookies;
        if (
$this->cookies == TRUE$this->cookie($cookie);
    }
    function 
cookie($cookie_file) {
        if (
file_exists($cookie_file)) {
            
$this->cookie_file=$cookie_file;
        } else {
            
fopen($cookie_file,'w') or $this->error('The cookie file could not be opened. Make sure this directory has the correct permissions');
            
$this->cookie_file=$cookie_file;
            
fclose($this->cookie_file);
        }
    }
    function 
post($url,$data) {
        
$process curl_init($url);
        
curl_setopt($processCURLOPT_HTTPHEADER$this->headers);
        
curl_setopt($processCURLOPT_HEADER1);
        
curl_setopt($processCURLOPT_USERAGENT$this->user_agent);
        if (
$this->cookies == TRUEcurl_setopt($processCURLOPT_COOKIEFILE$this->cookie_file);
        if (
$this->cookies == TRUEcurl_setopt($processCURLOPT_COOKIEJAR$this->cookie_file);
        
curl_setopt($processCURLOPT_ENCODING $this->compression);
        
curl_setopt($processCURLOPT_TIMEOUT30);
        if (
$this->proxycurl_setopt($processCURLOPT_PROXY$this->proxy);
        
curl_setopt($processCURLOPT_POSTFIELDS$data);
        
curl_setopt($processCURLOPT_RETURNTRANSFER1);
        
curl_setopt($processCURLOPT_FOLLOWLOCATION1);
        
curl_setopt($processCURLOPT_POST1);
        
$return curl_exec($process);
        
curl_close($process);
        return 
$return;
    }
    function 
error($error) {
        echo 
"<center><div style='width:500px;border: 3px solid #FFEEFF; padding: 3px; background-color: #FFDDFF;font-family: verdana; font-size: 10px'><b>cURL Error</b><br>$error</div></center>";
        die;
    }
}

$cc = new cURL();
$result=$cc->post($url,'email_address=$email&password=$pass');

echo 
$result
Al hacer el echo me muestra la web pero no estoy logueado.

¿Q puede estar pasando?

Última edición por GatorV; 23/03/2009 a las 19:10