OP\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
{
- // members
- private static $instance;
- private static $token;
- private static array $errors = ;
- private static string $restformat = 'json';
- private integer $count = 0;
- public boolean $proxy = false;
- public array $response = ;
- public array $header = ;
- public $info;
- public $error;
- private $options;
- private string $proxy_host = '';
- private string $proxy_auth = '';
- private string $proxy_type = '';
- private boolean $cookie = false;
- // methods
- public static MoodleWebservice|null connect()
- public static array getErrors()
- public static type getLocation()
- public MoodleResponse call()
- protected void __construct()
- private void __clone()
- private void __wakeup()
- public void resetopt()
- public void resetcookie()
- public void setopt()
- public void cleanopt()
- public void setHeader()
- public void getResponse()
- private int formatHeader()
- private apply_opt()
- public array download()
- protected void multi()
- protected bool request()
- private bool head()
- private void format_array_postdata_for_curlcall()
- private array format_postdata_for_curlcall()
- private bool post()
- private bool get()
- private bool put()
- private bool delete()
- public bool trace()
- public bool options()
- public void get_info()
Hierarchy
Uses
- SilverStripe\Core\Config\Configurable
Members
private
- $count
- $errors
- $instance
- $options
- $proxy_auth
- $proxy_host
- $proxy_type
- $restformat
- $token
public
- $error
- $header
- $info
- $proxy
- $response
Methods
private
- __clone() — Private clone method to prevent cloning of the instance of the *Singleton* instance.
- __wakeup() — Private unserialize method to prevent unserializing of the *Singleton instance.
- 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
- head() — HTTP HEAD 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.
- multi()
- request() — Single HTTP Request
public
- 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