Ver Mensaje Individual
  #1 (permalink)  
Antiguo 12/07/2009, 08:15
neojordan
 
Fecha de Ingreso: enero-2008
Mensajes: 97
Antigüedad: 16 años, 3 meses
Puntos: 3
Algo falta en curl

Buenas, intento loguearme en una web usando curl y parece que los datos del post se los paso bien, pero que falta algo o alguna opción, ya que me devuelve el siguiente mensaje:

Cita:
HTTP/1.1 200 OK Date: Fri, 10 Jul 2009 09:15:53 GMT Server: Apache/2.2.4 (Unix) mod_ssl/2.2.4 OpenSSL/0.9.8b PHP/5.1.6 X-Powered-By: PHP/5.1.6 Expires: Thu, 19 Nov 1981 08:52:00 GMT Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Pragma: no-cache Transfer-Encoding: chunked Content-Type: text/html
El codigo php es:

Código PHP:
<?php

$enlace 
$_GET['enlace'];

function 
curl($link$postfields ''$cookie '')
{
    
$ch curl_init($link);
    
curl_setopt($chCURLOPT_RETURNTRANSFER1);
    
curl_setopt($chCURLOPT_HEADER1);
    
curl_setopt($chCURLOPT_FOLLOWLOCATION1);
    if(
$postfields)
    {
        
curl_setopt($chCURLOPT_POST1);
        
curl_setopt($chCURLOPT_POSTFIELDS$postfields);
    }
    if(
$cookie)
    {
        
curl_setopt($chCURLOPT_COOKIEJAR$cookie);
        
curl_setopt($chCURLOPT_COOKIEFILE$cookie);
    }
    
$page curl_exec($ch);
    return(
$page);
    
curl_close($ch);
}

$postfields = array();
$postfields['uname'] = 'usuario';
$postfields['passwd'] = 'password';
//$postfields['d'] = 'Login'; Esto he probado a ponerlo y a no ponerlo. Es el valor del submit, pero no se si hay que ponerlo o no.
$postfields http_build_query($postfields);
$cookie 'php/cookie.txt'//Create a random named cookie file
$page curl('http://www.webjeemplo.com/login.php'$postfields$cookie); //Call the curl function with our arguments
$page curl($enlace''$cookie); //Go to the download page, with no postfields and premium cookie!

echo $page;

?>