I am trying to work with the recommeded parameters for providing a webservice for my plugin but I am a little stuck when I try to return a multi-dimensional array as JSON.
The function to validate outputs does not seem to cater for arrays regardless of which parameter (PARAM_RAW) I try to use.
public static function list_updated_returns() {
return new external_single_structure(
array(
'result' => new external_value(PARAM_RAW, 'result: array of updated simplefeedback questionnaires'),
'code' => new external_value(PARAM_INT, 'code: error code'),
'warnings' => new external_warnings()
)
);
}
For now I have to circumvent this by doing the following which I am happy to continue with, but I would like clarification if there is a Moodle way of doing this.
public static function list_updated($prevtime){
....... //generate $list_course_array array
......
......
if(!empty($list_course_array)){
$result['result'] = $list_course_array;
$result['code'] = '200';
header('Content-Type: application/json');
print json_encode($result);
die();
}
return $result;
}