I have the following PHP script which should get the content of a page, that is behind a login-form.
It is working fine on my localhost server, but it doesn\'t work
I solved it by first checking if open_basedir is set. If that is the case: the script first executes curl_exec() to set the cookies and then executes it again to get the hidden page. Parameters like op and form_build_id aren't used at all :P
Code:
if (ini_get('open_basedir') == '') {
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_MAXREDIRS, 10);
$postResult = curl_exec($ch);
curl_close($ch);
} else {
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
curl_exec($ch);
$postResult = curl_exec($ch);
}
form_build_id and CURLOPT_REFERER is missing You are suppose to send something like
name=user&pass=pass&op=Inloggen&form_build_id=form-fc3c69bda9d4a9a4a53e70f836ece383&form_id=login_block_login_form
Try adding the FOLLOWLOCATION option so it follows the redirect it's getting:
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);