Send instant message api

Send instant message api

by EAD Estágio 2 -
Number of replies: 1

I'm trying to send a message to specific User using the api moodle, but I'm not getting the return from the function says My parameters are incorrect.

See my code below:

$token = 'TOKENCODE';
    $domainname = 'http://urlmywebsite';
    $functionname = 'core_message_send_instant_messages';
    $restformat = 'json';
    $enrolment = new stdClass();
    $enrolment->touserid = 558;
    $enrolment->text = "Send message!"; 
    $enrolment->textformat = 1; 
    $enrolments = array( $enrolment);
    $params = array('enrolments' => $enrolments);
    $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);
    var_dump($resp);


Im using  core_message_send_instant_messages API

Can someone help me?


Average of ratings: -