Note: You are currently viewing documentation for Moodle 2.0. Up-to-date documentation for the latest stable version is available here: Web services (2.0 onwards).

Web services (2.0 onwards)

From MoodleDocs
Revision as of 23:39, 21 December 2010 by Gerwood Stewart (talk | contribs)

Adding web-services to a plugin (Moodle 2.0)

This is a work in progress. Please don't try following it just yet.

Overview

Web services are built and provided the the 'externallib.php' file in the modules (or areas) directory. In this file is kept the external class that extends the 'external_api' class and provides definitions for the incoming message format, outgoing message format and the worker functions for each service.

Extract from courses externallib.php

1. Create a new folder under grade/report

   grade/report/[newreport]

2. Create a /db sub-folder under the new report folder

   grade/report/[newreport]/db

3. Create an access.php file in the db folder with the following content. You should change the capabilities as needed.

   grade/report/[newreport]/db/access.php
 
   <?php

[code] defined('MOODLE_INTERNAL') || die;

require_once("$CFG->libdir/externallib.php");

class moodle_course_external extends external_api { }

[code]