io ho un utente con id 30;
ruolo corso student id 5;
e il corso ha un id 5;
lo script che ho generato è questo:
<?php
$token = 'f4e2932b2969768c4a9de692b86c40e4';
$domainname = 'http://192.168.1.3/testbarone/moodle';
$functionname = 'enrol_manual_enrol_users';
$restformat = 'xml';
$enrolment = new stdClass();
$enrolment->roleid = 5;
$enrolment->userid = 30;
$enrolment->courseid = 5;
$params = array($enrolment);
header('Content-Type: text/plain');
$serverurl = $domainname . '/webservice/rest/server.php'. '?wstoken=' . $token . '&wsfunction='.$functionname;
require_once('./curl.php');
$curl = new curl;
$restformat = ($restformat == 'json')?'&moodlewsrestformat=' . $restformat:'';
$resp = $curl->post($serverurl . $restformat, $params);
print_r($resp);
$xmldat=simplexml_load_string($resp);
//print_r ($xmldat);
if (isset($xmldat->MULTIPLE->SINGLE->KEY[0])) {
$ris = $xmldat->MULTIPLE->SINGLE->KEY[0];
echo $ris['name'];
echo $xmldat->MULTIPLE->SINGLE->KEY[0]->VALUE;
}
else
echo "errore!";
//print_r ($xmldat->multiple->single->key[0]);
//$i= $xmldat->item->name;
?>
MA MI GENERA IL SEGUENTE ERRORE:
<?xml version="1.0" encoding="UTF-8" ?>
<EXCEPTION class="invalid_parameter_exception">
<ERRORCODE>invalidparameter</ERRORCODE>
<MESSAGE>E' stato rilevato un parametro non valido</MESSAGE>
</EXCEPTION>
errore!
quali sono i parametri che sbaglio a passare? In allegato il codice