PHPXMLRPC 4.11.0

Request
in package
uses CharsetEncoderAware, DeprecationLogger, ParserAware, PayloadBearer

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.

Tags
todo

feature creep - add a protected $httpRequest member, in the same way the Response has one

Table of Contents

Properties

$content_type  : string
$debug  : int
$methodname  : string
$params  : array<string|int, Value>
$payload  : string
$charsetEncoder  : mixed
$content_type  : string
$debug  : int
$methodname  : string
$params  : array<string|int, Value>
$parser  : mixed
$payload  : string
$httpResponse  : mixed
holds data while parsing the response. NB: Not a full Response object

Methods

__construct()  : mixed
__get()  : mixed
__isset()  : mixed
__set()  : mixed
__unset()  : mixed
addParam()  : bool
Add a parameter to the list of parameters to be used upon method invocation.
getCharsetEncoder()  : mixed
getContentType()  : string
getNumParams()  : int
Returns the number of parameters in the message.
getParam()  : Value
Returns the nth parameter in the request. The index zero-based.
getParser()  : mixed
getPayload()  : string
kindOf()  : string
Kept the old name even if Request class was renamed, for BC.
method()  : string
Gets/sets the xml-rpc method to be invoked.
parseResponse()  : Response
Parse the xml-rpc response contained in the string $data and return a Response object.
parseResponseFile()  : Response
Given an open file handle, read all data available and parse it as an xml-rpc response.
serialize()  : string
Returns xml representation of the message, XML prologue included. Sets `payload` and `content_type` properties
setCharsetEncoder()  : void
setDebug()  : $this
Enables/disables the echoing to screen of the xml-rpc responses received.
setParser()  : void
logDeprecation()  : mixed
logDeprecationUnlessCalledBy()  : void

Properties

$content_type

public string $content_type

deprecated - public access left in purely for BC. Access via getContentType()/setPayload()

$debug

public int $debug

deprecated - public access left in purely for BC. Access via .../setDebug()

$methodname

public string $methodname

deprecated - public access left in purely for BC. Access via method()/__construct()

$params

public array<string|int, Value> $params

deprecated - public access left in purely for BC. Access via getParam()/__construct()

$payload

public string $payload

deprecated - public access left in purely for BC. Access via getPayload()/setPayload()

$methodname

protected string $methodname

$httpResponse

holds data while parsing the response. NB: Not a full Response object

will be removed in a future release; still accessible by subclasses for the moment

private mixed $httpResponse = array()

Methods

__construct()

public __construct(string $methodName[, array<string|int, Value$params = array() ]) : mixed
Parameters
$methodName : string

the name of the method to invoke

$params : array<string|int, Value> = array()

array of parameters to be passed to the method (NB: Value objects, not plain php values)

__get()

public & __get(mixed $name) : mixed
Parameters
$name : mixed

__isset()

public __isset(mixed $name) : mixed
Parameters
$name : mixed

__set()

public __set(mixed $name, mixed $value) : mixed
Parameters
$name : mixed
$value : mixed

__unset()

public __unset(mixed $name) : mixed
Parameters
$name : mixed

addParam()

Add a parameter to the list of parameters to be used upon method invocation.

public addParam(Value $param) : bool

Checks that $params is actually a Value object and not a plain php value.

Parameters
$param : Value
Return values
bool

false on failure

getContentType()

public getContentType() : string
Return values
string

getNumParams()

Returns the number of parameters in the message.

public getNumParams() : int
Return values
int

the number of parameters currently set

getParam()

Returns the nth parameter in the request. The index zero-based.

public getParam(int $i) : Value
Parameters
$i : int

the index of the parameter to fetch (zero based)

Return values
Value

the i-th parameter

getPayload()

public getPayload() : string
Return values
string

kindOf()

Kept the old name even if Request class was renamed, for BC.

public kindOf() : string
Return values
string

method()

Gets/sets the xml-rpc method to be invoked.

public method([string $methodName = '' ]) : string
Parameters
$methodName : string = ''

the method to be set (leave empty not to set it)

Return values
string

the method that will be invoked

parseResponse()

Parse the xml-rpc response contained in the string $data and return a Response object.

public parseResponse([string $data = '' ][, bool $headersProcessed = false ][, string $returnType = XMLParser::RETURN_XMLRPCVALS ]) : Response

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

Parameters
$data : string = ''

the xml-rpc response, possibly including http headers

$headersProcessed : bool = false

when true prevents parsing HTTP headers for interpretation of content-encoding and consequent decoding

$returnType : string = XMLParser::RETURN_XMLRPCVALS

decides return type, i.e. content of response->value(). Either 'xmlrpcvals', 'xml' or 'phpvals'

Tags
todo

parsing Responses is not really the responsibility of the Request class. Maybe of the Client...

todo

what about only populating 'raw_data' in httpResponse when debug mode is > 0?

todo

feature creep - allow parsing data gotten from a stream pointer instead of a string: read it piecewise, looking first for separation between headers and body, then for charset indicators, server debug info and </methodResponse>. That would require a notable increase in code complexity...

Return values
Response

parseResponseFile()

Given an open file handle, read all data available and parse it as an xml-rpc response.

public parseResponseFile(resource $fp[, bool $headersProcessed = false ][, string $returnType = 'xmlrpcvals' ]) : 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...

Parameters
$fp : resource

stream pointer

$headersProcessed : bool = false
$returnType : string = 'xmlrpcvals'
Tags
todo

arsing Responses is not really the responsibility of the Request class. Maybe of the Client...

todo

feature creep - add a flag to disable trying to parse the http headers

Return values
Response

serialize()

Returns xml representation of the message, XML prologue included. Sets `payload` and `content_type` properties

public serialize([string $charsetEncoding = '' ]) : string
Parameters
$charsetEncoding : string = ''
Return values
string

the xml representation of the message, xml prologue included

setCharsetEncoder()

public static setCharsetEncoder(mixed $charsetEncoder) : void
Parameters
$charsetEncoder : mixed

setDebug()

Enables/disables the echoing to screen of the xml-rpc responses received.

public setDebug(int $level) : $this
Parameters
$level : int

values <0, 0, 1, >1 are supported

Return values
$this

setParser()

public static setParser(mixed $parser) : void
Parameters
$parser : mixed

logDeprecation()

protected logDeprecation(mixed $message) : mixed
Parameters
$message : mixed

logDeprecationUnlessCalledBy()

protected logDeprecationUnlessCalledBy(string $expectedCaller) : void
Parameters
$expectedCaller : string

atm only the method name is supported


        
On this page

Search results