I'm using CURL to log in to access my data but they have a field that generates a new key everytime I reload the page.
My attempt was to extract the key value first, then include it to my postfield log in. When I do this, a new key has been generated making the extracted key useless.
<?php
$curl_handle = curl_init($url);
curl_setopt($curl_handle, CURLOPT_COOKIEFILE, 'cookie.txt');
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
$buffer = curl_exec($curl_handle);
curl_close($curl_handle);
preg_match("/<input type=\"hidden\" name=\"key\" value=\"([a-zA-Z0-9]+)\" \/>/", $buffer, $match);
$hiddenkey = $match[1];
$fields_string = urlencode("email=EMAIL&passfield=PASS&pass=&attempts=&submit=Login&key=" . $hiddenkey);
$curl_handle = curl_init($url);
curl_setopt($curl_handle, CURLOPT_URL, $url);
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl_handle, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt($curl_handle, CURLOPT_POSTFIELDS, $fields_string);
curl_setopt($curl_handle, CURLOPT_FOLLOWLOCATION, 1);
$buffer = curl_exec($curl_handle);
curl_close($curl_handle);
?>