Sunnysideup\Moodle\Api\MoodleWebservice
Silverstripe Moodle webservice client. Utilises REST/JSON. JSON is only supported under Moodle 2.2 and above.
Parts of the script were utlised by Moodle's cURL wrapper.
Synopsis
class MoodleWebservice
{
- // constants
- const WEB_SERVER_LOCATION = 'webservice/rest/server.php';
- // members
- public boolean $proxy = false;
- public array $response = ;
- public array $header = ;
- public $info;
- public $error;
- protected static $altMoodleRest;
- private boolean $debug = false;
- private static $instance;
- private static $token;
- private static array $errors = ;
- private static string $restformat = 'json';
- private integer $count = 0;
- private static array $authentication = ;
- private $options;
- private string $proxy_host = '';
- private string $proxy_auth = '';
- private string $proxy_type = '';
- private boolean $cookie = false;
- // methods
- protected void __construct()
- public void QuickCall()
- public static null|MoodleWebservice connect()
- public static array getErrors()
- public static string getLocation()
- public MoodleResponse call()
- public void resetopt()
- public void resetcookie()
- public void setopt()
- public void cleanopt()
- public void setHeader()
- public void getResponse()
- public array download()
- public void trace()
- public void options()
- public void get_info()
- protected void getQuickCommandApi()
- protected void multi()
- protected bool request()
- private int formatHeader()
- private apply_opt()
- private void format_array_postdata_for_curlcall()
- private array format_postdata_for_curlcall()
- private void post()
- private void get()
- private void put()
- private void delete()
Hierarchy
Uses
- SilverStripe\Core\Config\Configurable
- SilverStripe\Core\Injector\Injectable
Constants
Name | Value |
---|---|
WEB_SERVER_LOCATION | 'webservice/rest/server.php' |
Members
private
- $authentication
- $count
- $debug
- $errors
- $instance
- $options
- $proxy_auth
- $proxy_host
- $proxy_type
- $restformat
- $token
protected
- $altMoodleRest
public
- $error
- $header
- $info
- $proxy
- $response
Methods
private
- apply_opt() — Set options for individual curl instance.
- delete() — HTTP DELETE method.
- formatHeader() — private callback function Formatting HTTP Response Header.
- format_array_postdata_for_curlcall() — Recursive function formating an array in POST parameter.
- format_postdata_for_curlcall() — Transform a PHP array into POST parameter (see the recursive function format_array_postdata_for_curlcall).
- get() — HTTP GET method.
- post() — HTTP POST method.
- put() — HTTP PUT method.
protected
- __construct() — Protected constructor to prevent creating a new instance of the *Singleton* via the 'connect' operator from outside of this class.
- getQuickCommandApi()
- multi()
- request() — Single HTTP Request.
public
- QuickCall()
- call() — will call the remote request to the moodle server.
- cleanopt() — Reset http method.
- connect() — asks Moodle for token. If it fails it will return a null object. You can see errors by looking at MoodleWebservice::getErrors().
- download() — Download multiple files in parallel.
- getErrors() — returns an array of errors.
- getLocation() — checks the environment type, and returns the connection string.
- getResponse() — Set HTTP Response Header.
- get_info()
- options() — HTTP OPTIONS method.
- resetopt() — Resets the CURL options that have already been set.
- setHeader() — Set HTTP Request Header.
- setopt() — sets the cURL options.
- trace() — HTTP TRACE method.