Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-22965

Create Moodle REST client

    XMLWordPrintable

    Details

    • Type: Task
    • Status: Closed
    • Priority: Minor
    • Resolution: Duplicate
    • Affects Version/s: 2.0
    • Fix Version/s: None
    • Component/s: Hub, Web Services
    • Labels:
    • Affected Branches:
      MOODLE_20_STABLE

      Description

      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
          }
      }

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: