Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Differences Between: [Versions 401 and 402] [Versions 401 and 403]

(no description)

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

Defines 1 class

Request:: (19 methods):
  getLogger()
  setLogger()
  getParser()
  setParser()
  getCharsetEncoder()
  setCharsetEncoder()
  __construct()
  xml_header()
  xml_footer()
  createPayload()
  method()
  serialize()
  addParam()
  getParam()
  getNumParams()
  parseResponseFile()
  parseResponse()
  kindOf()
  setDebug()


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.

getLogger()   X-Ref
No description

setLogger($logger)   X-Ref
No description

getParser()   X-Ref
No description

setParser($parser)   X-Ref
No description

getCharsetEncoder()   X-Ref
No description

setCharsetEncoder($charsetEncoder)   X-Ref
No description

__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)

xml_header($charsetEncoding = '')   X-Ref

param: string $charsetEncoding
return: string

xml_footer()   X-Ref

return: string

createPayload($charsetEncoding = '')   X-Ref

param: string $charsetEncoding

method($methodName = '')   X-Ref
Gets/sets the xmlrpc 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

serialize($charsetEncoding = '')   X-Ref
Returns xml representation of the message. XML prologue included.

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

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

parseResponseFile($fp, $headersProcessed = false, $returnType = 'xmlrpcvals')   X-Ref
Given an open file handle, read all data available and parse it as an xmlrpc 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 xmlrpc 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 xmlrpc 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 compatibility.

return: string

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

param: integer $level values 0, 1, 2 are supported