General developer forum

I created a PHP class to make REST requests to Moodle webservices

 
Picture of Lawrence Lagerlof
I created a PHP class to make REST requests to Moodle webservices
 

Hi devs. I create this small tool to make my life easier. The goal is to build requests to the Moodle webservice (REST) functions. I called it MoodleRest and it's opensource. You can get the returned data in the format: array, json or xml.

You can do this in plain PHP of course, but this class helps to manage the URL, the token, the URL parameters and the returned data.


Usage example:



require_once "MoodleRest.php";

$MoodleRest = new MoodleRest('http://127.0.0.1/moodle/webservice/rest/server.php', '8f12e614dae30735260a045313caa400');

$groups = $MoodleRest->request('core_group_get_groups', array('groupids' => array(1,2)));

print_r($groups);


You can get this tool, made with love, in the Github repository.



 
Average of ratings: -