llagerlof / MoodleRest

MoodleRest is a PHP class to query Moodle REST webservices
MIT License
86 stars 21 forks source link

Request to call before core_user_get_course_user_profiles #4

Closed haikajymada closed 3 years ago

haikajymada commented 3 years ago

Hello, I'm using it from your example :

$MoodleRest = new MoodleRest();
$MoodleRest->setServerAddress("http://$ip/$moodle_folder/webservice/rest/server.php");
$MoodleRest->setToken($token);
$MoodleRest->setReturnFormat(MoodleRest::RETURN_ARRAY);

$result1 = $MoodleRest->request('core_group_get_groups', array('groupids' => array(1,2))); // groupids[0]=1&groupids[1]=2

echo "result1:\n" . print_r($result1, true);
$params = array('userlist' => array(array('userid' => 3, 'courseid' => 3), array('userid' => 5, 'courseid' => 3))); //userlist[0][userid]=5&userlist[1][userid]=4&userlist[0][courseid]=2&userlist[1][courseid]=2

$result2 = $MoodleRest->request('core_user_get_course_user_profiles', $params);

echo "result2:\n" . print_r($result2, true);
die();

what I get back is "Array ( [exception] => webservice_access_exception [errorcode] => accessexception [message] => Exception du contrôle d'accès" it's about not having access to core_user_get_course_user_profiles which is a login-required fonction.

What I have to call before this request ?