今天是个好日子。我目前正在 Moodle 中编程。由于我在他们的论坛上还没有得到任何答案,我将不得不在这里提问,因为我真的非常需要帮助。我的 cURL 如何绕过 Moodle 登录页面?
$ckfile = tempnam("/tmp","CURLCOOKIE");
$ch = curl_init(http://127.0.0.1/login/index.php);
$data = array('username' => 'admin', 'password' => 'Admin_123');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_COOKIEJAR, $ckfile);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$url = "http://127.0.0.1/mod/quiz/report.php?q=4&mode=analysis";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_COOKIEFILE, $ckfile);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec($ch);
echo $output;
curl_close($ch);
鉴于此代码,我已成功以管理员身份登录,但问题是我仍然停留在登录页面而不是继续访问 url (http://127.0.0.1/mod/quiz/report.php?q= 4&mode=analysis) 这应该是我的目标。我该如何绕过登录页面?任何帮助将不胜感激。谢谢!