hatching Posted December 19, 2008 Share Posted December 19, 2008 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); ?> Link to comment https://forums.phpfreaks.com/topic/137757-curl-cant-log-in-bc-key-field-changes-value/ Share on other sites More sharing options...
flyhoney Posted December 19, 2008 Share Posted December 19, 2008 Grab the contents of the login page. Extract the key from the form. Post username, password and key to log in. If you are doing things in that order I dont see how they could generate a new key. I tried doing what you are doing for a private torrent tracker site and gave up because it was too frustrating Link to comment https://forums.phpfreaks.com/topic/137757-curl-cant-log-in-bc-key-field-changes-value/#findComment-720024 Share on other sites More sharing options...
hatching Posted December 20, 2008 Author Share Posted December 20, 2008 After I generated my key, I echoed the curl_exec of the page where I made a POST with the key and the keys didn't match. Link to comment https://forums.phpfreaks.com/topic/137757-curl-cant-log-in-bc-key-field-changes-value/#findComment-720050 Share on other sites More sharing options...
hatching Posted December 24, 2008 Author Share Posted December 24, 2008 Any idea on a workaround? Link to comment https://forums.phpfreaks.com/topic/137757-curl-cant-log-in-bc-key-field-changes-value/#findComment-723020 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.