MDL-30495 HTML5 apps cannot call Webservices functions if a HTTP resource is retrieve...
[moodle.git] / webservice / rest / server.php
CommitLineData
dee7b68b 1<?php
cc93c7da 2
3// This file is part of Moodle - http://moodle.org/
4//
5// Moodle is free software: you can redistribute it and/or modify
6// it under the terms of the GNU General Public License as published by
7// the Free Software Foundation, either version 3 of the License, or
8// (at your option) any later version.
9//
10// Moodle is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15// You should have received a copy of the GNU General Public License
16// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
17
dee7b68b 18/**
cc93c7da 19 * REST web service entry point. The authentication is done via tokens.
06e7fadc 20 *
06e7fadc 21 * @package webservice
cc93c7da 22 * @copyright 2009 Moodle Pty Ltd (http://moodle.com)
23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
06e7fadc 24 */
25
ad3abe20
PS
26// disable moodle specific debug messages and any errors in output
27define('NO_DEBUG_DISPLAY', true);
cc93c7da 28define('NO_MOODLE_COOKIES', true);
dee7b68b 29
cc93c7da 30require('../../config.php');
31require_once("$CFG->dirroot/webservice/rest/locallib.php");
dee7b68b 32
cc93c7da 33if (!webservice_protocol_is_enabled('rest')) {
c6c7b334 34 die;
35}
36
a08b4cc8
JM
37$restformat = optional_param('moodlewsrestformat', 'xml', PARAM_ALPHA);
38//remove the alt from the request
a08b4cc8
JM
39if(isset($_GET['moodlewsrestformat'])) {
40 unset($_GET['moodlewsrestformat']);
41}
42if(isset($_POST['moodlewsrestformat'])) {
43 unset($_POST['moodlewsrestformat']);
44}
45
46$server = new webservice_rest_server(WEBSERVICE_AUTHMETHOD_PERMANENT_TOKEN, $restformat);
2458e30a 47$server->run();
cc93c7da 48die;
06e7fadc 49