I have connected Unity to Moodle using PHP. I can successfully generate user token in Unity, but when ad will send a post request to Moodle using my custom plugin in Moodle I get this error.
response: <?xml version="1.0" encoding="UTF-8" ?>
<EXCEPTION class="invalid_parameter_exception">
<ERRORCODE>invalidparameter</ERRORCODE>
<MESSAGE>Invalid parameter value detected (Missing function name)</MESSAGE>
<DEBUGINFO>Missing function name</DEBUGINFO>
</EXCEPTION>
I know the error is because of Missing function name but I added it correctly in my query like :
$parametersArray = array('wstoken' => $token , 'wsfunction' => $function , 'moodlewsrestformat' => 'json'');
this is the code for curl that I use
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded'));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($curl);
curl_close($curl);
return $response;
I add wsfunction like core_course_get_module. of course I add id=99 to $parametersArray after that line.