If you have experimented with the Moodle Web Services then you will find there are pockets of information that can be pieced together to help understand how the API’s work.

Below is a list of links to pages and sites that I have found extremely useful when it comes to putting together an external web service.

Moodle web service links

The first most important page is on your Moodle server.

yourmoodleserver/admin/webservice/documentation.php

This will list all the web service functions that you have available and describe the schema for each service in different protocols.

Current web service functions from the Moodle documentation.

https://docs.moodle.org/dev/Web_service_API_functions

Using web services – setting up the service on Moodle

https://docs.moodle.org/37/en/Using_web_services

Creating a web service client

https://docs.moodle.org/dev/Creating_a_web_service_client

Getting started list of steps to setup web services in Moodle

https://support.ecreators.com.au/hc/en-us/articles/360000719416-Step-by-Step-Instructions-for-how-Setup-external-services-Web-Services-within-Moodle

Step by step setup

https://moodle.org/mod/forum/discuss.php?d=319039

Quick Web service setup and test

https://benit.github.io/blog/2017/03/29/consumming-a-moodle-webservice/

Example: Save grades using PHP.

https://gist.github.com/hig3/a34e896d0ce44f872188

Download CURL if you are using PHP as your server side code from here.

Some code to get you started

If you just want some code to get you started, the below code is the core of what you will need.

Make sure you setup your Moodle service as recommended in the above links to allow web services and setup a user account with a token.

Enrol the user with the web service token into the course you are going to test with.

Remember that your account must have permission to use a web service.

I am assuming you are using PHP as the external application server to call the Moodle web services?

On a PHP server, download the CURL PHP file from above and add it to your web server to be included by the code below.

Create a PHP testwebservice.php page and add the following code.

Replace courseid_as_integer with your test course ID.  

This will return the details about the course ID that you set as JSON data.


Need more information….. Join the NEW Moodle Administrators and Developers group

https://www.facebook.com/groups/1616484371816446/

Pin It on Pinterest

Share This