Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.2.x will end 22 April 2024 (12 months).
  • Bug fixes for security issues in 4.2.x will end 7 October 2024 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.1.x is supported too.

Differences Between: [Versions 401 and 402]

(no description)

File Size: 563 lines (24 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

Request:: (17 methods):
  __construct()
  method()
  addParam()
  getParam()
  getNumParams()
  serialize()
  createPayload()
  xml_header()
  xml_footer()
  parseResponseFile()
  parseResponse()
  kindOf()
  setDebug()
  __get()
  __set()
  __isset()
  __unset()


Class: Request  - X-Ref

This class provides the representation of a request to an XML-RPC server.
A client sends a PhpXmlrpc\Request to a server, and receives back an PhpXmlrpc\Response.

__construct($methodName, $params = array()   X-Ref

param: string $methodName the name of the method to invoke
param: Value[] $params array of parameters to be passed to the method (NB: Value objects, not plain php values)

method($methodName = '')   X-Ref
Gets/sets the xml-rpc method to be invoked.

param: string $methodName the method to be set (leave empty not to set it)
return: string the method that will be invoked

addParam($param)   X-Ref
Add a parameter to the list of parameters to be used upon method invocation.
Checks that $params is actually a Value object and not a plain php value.

param: Value $param
return: boolean false on failure

getParam($i)   X-Ref
Returns the nth parameter in the request. The index zero-based.

param: integer $i the index of the parameter to fetch (zero based)
return: Value the i-th parameter

getNumParams()   X-Ref
Returns the number of parameters in the message.

return: integer the number of parameters currently set

serialize($charsetEncoding = '')   X-Ref
Returns xml representation of the message, XML prologue included. Sets `payload` and `content_type` properties

param: string $charsetEncoding
return: string the xml representation of the message, xml prologue included

createPayload($charsetEncoding = '')   X-Ref

param: string $charsetEncoding
return: void

xml_header($charsetEncoding = '')   X-Ref

param: string $charsetEncoding
return: string

xml_footer()   X-Ref

return: string

parseResponseFile($fp, $headersProcessed = false, $returnType = 'xmlrpcvals')   X-Ref
Given an open file handle, read all data available and parse it as an xml-rpc response.

NB: the file handle is not closed by this function.
NNB: might have trouble in rare cases to work on network streams, as we check for a read of 0 bytes instead of
feof($fp). But since checking for feof(null) returns false, we would risk an infinite loop in that case,
because we cannot trust the caller to give us a valid pointer to an open file...

param: resource $fp stream pointer
param: bool $headersProcessed
param: string $returnType
return: Response

parseResponse($data = '', $headersProcessed = false, $returnType = XMLParser::RETURN_XMLRPCVALS)   X-Ref
Parse the xml-rpc response contained in the string $data and return a Response object.

When $this->debug has been set to a value greater than 0, will echo debug messages to screen while decoding.

param: string $data the xml-rpc response, possibly including http headers
param: bool $headersProcessed when true prevents parsing HTTP headers for interpretation of content-encoding and
param: string $returnType decides return type, i.e. content of response->value(). Either 'xmlrpcvals', 'xml' or
return: Response

kindOf()   X-Ref
Kept the old name even if Request class was renamed, for BC.

return: string

setDebug($level)   X-Ref
Enables/disables the echoing to screen of the xml-rpc responses received.

param: integer $level values <0, 0, 1, >1 are supported
return: $this

__get($name)   X-Ref
No description

__set($name, $value)   X-Ref
No description

__isset($name)   X-Ref
No description

__unset($name)   X-Ref
No description