LMSouq
moodle-core Open

Help pertaining to cURL on Moodle

PO
POGI
1 month ago
3 views
Problem Description
Good day everyone. I'm currently programming in Moodle. Since I haven't got any answers yet in their forums I will have to ask it here because I really need help badly. How can my cURL bypass Moodle login page? $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); Given this code, I have successfully logged in as admin but the problem is that I'm still stuck in the login page instead of proceeding to the url (http://127.0.0.1/mod/quiz/report.php?q=4&mode=analysis) which is supposed to be my target. How am I suppose to bypass the login page? Any help would be greatly appreciated. Thanks!

AI-Generated Solution

Powered by LMSouq AI · GPT-4.1-mini

✓ Solution Ready
Analyzing problem and generating solution…
Was this solution helpful?
Back to Knowledge Base