curl / Mailing Lists / curl-users / Single Mail
Buy commercial curl support from WolfSSL. We help you work out your issues, debug your libcurl applications, use the API, port to new platforms, add new features and more. With a team lead by the curl founder himself.

Re: can't login with curl in forum (mierdatutis mi)

From: Hans Henrik Bergan via curl-users <>
Date: Thu, 21 May 2020 00:36:39 +0200

logging in there isn't a job for curl, it includes HTML parsing, and you
cannot hardcode the csrf token, `c13a08a29` in your login request is a CSRF
token, and it is a 1-time token, it was only valid the 1 time your browser
used it to login, and will never be valid again, you must always fetch a
fresh token from on every login
attempt, also your login url is dynamic, you cannot hardcode that either,
you try to send the login request to , but the real login url is
dynamic and looks something like
(with PHPSESSID being dynamic)

use a scripting language, like PHP, Python, Perl, or anything with a
wrapper for libcurl and libxml2, here's a sample login in PHP using php's
libcurl+ libxml2 wrappers,
$ch = curl_init();
curl_setopt_array($ch, array(
    CURLOPT_URL => '',
    // setting CURLOPT_COOKIEFILE to emptystring enables the cookie engine
// should look like:
//var_dump($loginUrl) & die();
foreach($loginForm->getElementsByTagName("input") as $input){

// should look like:
array (
    'user' => '',
    'passwrd' => '',
    'cookielength' => '120',
    'cookieneverexp' => '',
    '' => 'Ingresar',
    'd071bb5935' => 'b98cf923a5962f4184c3d020a65c0ca1',
    'hash_passwrd' => '',
assert(isset($loginParams['user']) && isset($loginParams['passwrd']));
$xp=new DOMXPath($domd);
// <p class="error">Nombre de usuario no existente.</p>

that script outputs:

    [loginError] => Nombre de usuario no existente.

presumably because is not a real email address.

Received on 2020-05-21