Hola, siguiendo un post que está más o menos bien sobre como iniciar sesión me queda así:
PHP:
$input = array("email" => "", "passwd" => "");
$url = ""
foreach($input as $name=>$value){
$elements[] = "{$name}=".urlencode($value);
}
$handler = curl_init();
curl_setopt($handler, CURLOPT_URL, $url)
curl_setopt($handler, CURLOPT_RETURNTRANSFER, true);
curl_setopt($handler, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($handler, CURLOPT_COOKIESESSION, true);
curl_setopt($handler, CURLOPT_POST, true);
curl_setopt($handler, CURLOPT_FRESH_CONNECT, true);
curl_setopt($handler, CURLOPT_POSTFIELDS, $elements);
curl_setopt($handler, CURLOPT_COOKIEJAR,"cookie.txt");
curl_setopt($handler, CURLOPT_COOKIEFILE,"cookie.txt");
$response = curl_exec($handler);
curl_close($handler);
print $response;
Pero me manda este error al lanzarlo:
Parse error: syntax error, unexpected 'foreach' (T_FOREACH) in C:\xampp\htdocs\login.php on line 7
Muchas gracias por atenderme.
EDITO:
El error ese era por un punto y coma ahora me da este:
Parse error: syntax error, unexpected 'curl_setopt' (T_STRING) in C:\xampp\htdocs\login.php on line 14
Refiriendose al 2º curl_setopt
EDITO 2:
El otro setopt tampoco tenía ";" xD, ahora simplemente no hace login igual que al principio.
---------- Post agregado el 29-jun-2013 hora: 00:27 ----------
Mi problema es que no puedo incluir el useragent (CREO), ya que este script se ejecuta con un cron job entonces cual sería el useragent (?)