-
Task
-
Resolution: Duplicate
-
Minor
-
None
-
2.0
-
MOODLE_20_STABLE
A Moodle REST client would be useful for web services and also hub.
/**
|
* REST client class
|
*/
|
class webservice_rest_client {
|
/**
|
* Execute client WS request with token authentication
|
* @param string $entrypointurl
|
* @param string $token
|
* @param string $functionname
|
* @param array $params
|
* @return mixed
|
*/
|
public function call($entrypointurl, $token, $functionname, $params) {
|
global $DB, $CFG;
|
|
//traditional Zend xmlrpc client call (integrating the token into the URL)
|
$serverurl = $entrypointurl."?wstoken=".$token;
|
$result = download_file_content($serverurl.'&wsfunction='.$functionname, null, $params);
|
$result = convert_xml_to_object($result);
|
return $result;
|
}
|
|
/**
|
* Convert the REST XML response into php object/array/primary type
|
* @param string $xml
|
*/
|
public function convert_xml_to_object($xml) {
|
//TO DO
|
}
|
}
|