X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=blobdiff_plain;f=lib%2FXmlRpcClient.php;h=886198b3662cac58d6a59952acaa686f77432507;hp=f36347d91a1e4cbb5f14f56007f642f61456a251;hb=bc0d0be07283bb4669e17528e347cd3870656136;hpb=e78857a010ae86f5dddb593cbe96d67e5bd6f13d diff --git a/lib/XmlRpcClient.php b/lib/XmlRpcClient.php index f36347d..886198b 100644 --- a/lib/XmlRpcClient.php +++ b/lib/XmlRpcClient.php @@ -11,7 +11,7 @@ * listdomain(array('domain' => 'example.com')); + * print_r($rpc->listdomain(array('domain' => 'example.com'))); * } catch (Exception $ex) { * echo $ex; * } @@ -30,69 +30,69 @@ class XmlRpcClient * * @var string */ - public $namespace; - - /** - * HttpRequest instance - * - * @var HttpRequest - */ - protected $request; + public $namespace; + + /** + * HttpRequest instance + * + * @var HttpRequest + */ + protected $request; - /** - * Constructor - * - * @param string $url RPC endpoint - * @param string $namespace RPC namespace - */ - public function __construct($url, $namespace = '') - { - $this->namespace = $namespace; - $this->request = new HttpRequest($url, HTTP_METH_POST); - $this->request->setContentType('text/xml'); - } + /** + * Constructor + * + * @param string $url RPC endpoint + * @param string $namespace RPC namespace + */ + public function __construct($url, $namespace = '') + { + $this->namespace = $namespace; + $this->request = new HttpRequest($url, HTTP_METH_POST); + $this->request->setContentType('text/xml'); + } - /** - * Proxy to HttpRequest::setOptions() - * - * @param array $options - * @return unknown - */ - public function setOptions(array $options = null) - { - return $this->request->setOptions($options); - } - - /** - * Get associated HttpRequest instance - * - * @return HttpRequest - */ - public function getRequest() - { - return $this->request; - } + /** + * Proxy to HttpRequest::setOptions() + * + * @param array $options + * @return unknown + */ + public function setOptions(array $options = null) + { + return $this->request->setOptions($options); + } + + /** + * Get associated HttpRequest instance + * + * @return HttpRequest + */ + public function getRequest() + { + return $this->request; + } - /** - * RPC method proxy - * - * @param string $method RPC method name - * @param array $params RPC method arguments - * @return mixed decoded RPC response - * @throws Exception - */ - public function __call($method, array $params) - { - if ($this->namespace) { - $method = $this->namespace .'.'. $method; - } - $this->request->setRawPostData(xmlrpc_encode_request($method, $params)); - $response = $this->request->send(); - if ($response->getResponseCode() != 200) { - throw new Exception($response->getBody(), $response->getResponseCode()); - } - return xmlrpc_decode($response->getBody(), 'utf-8'); - } + /** + * RPC method proxy + * + * @param string $method RPC method name + * @param array $params RPC method arguments + * @return mixed decoded RPC response + * @throws Exception + */ + public function __call($method, array $params) + { + if ($this->namespace) { + $method = $this->namespace .'.'. $method; + } + $this->request->setRawPostData(xmlrpc_encode_request($method, $params)); + $response = $this->request->send(); + if ($response->getResponseCode() != 200) { + throw new Exception($response->getBody(), $response->getResponseCode()); + } + return xmlrpc_decode($response->getBody(), 'utf-8'); + } } ?>