I have logged into a website by posting data with curl. I now want to display the page that a user would normally see after logging in but I can’t because the url always changes.
http://some.example.com/niceday/foobar.php?TID=abcd
where abcd is some seemingly random number.
I’ve been trying to get the response headers but it keeps giving me the request headers I just sent.
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://example.com/niceday/dirlogin.php'); //login URL
curl_setopt ($ch, CURLOPT_POST, 1);
$postData = 'userName=scott&password=abc123& etc...';
curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, true );
curl_setopt( $ch, CURLOPT_ENCODING, "" );
curl_setopt( $ch, CURLOPT_AUTOREFERER, true );
curl_setopt ($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_NOBODY, true);
$store = curl_exec($ch);
$info = curl_getinfo($ch);
print_r($info);//wrong headers are printed out
The headers for the curl_exec($ch) are shown but how do I get the response headers?
I’m not sure if it’s relevant but the form where the login credentials are entered uses javascript
YOu can get the response header line this :
$headers = curl_getinfo($ch);But i can’t see how it will help you with your problem and then you can usehttp_parse_header()orexplode("\n", $headers);update :
This will return only the headers.