4 * XMLRPC Client, very KISS
7 * NOTE: requires ext/xmlrpc
12 * $rpc = new XmlRpcClient('http://mike:secret@example.com/cgi-bin/vpop-xmlrpc', 'vpop');
13 * $rpc->options = array(array('compress' => true));
15 * print_r($rpc->listdomain(array('domain' => 'example.com')));
16 * } catch (Exception $ex) {
22 * @copyright Michael Wallner, <mike@iworks.at>
23 * @license BSD, revised
37 * HttpRequest instance
46 * @param string $url RPC endpoint
47 * @param string $namespace RPC namespace
49 public function __construct($url, $namespace = '')
51 $this->namespace = $namespace;
52 $this->request
= new HttpRequest($url, HTTP_METH_POST
);
53 $this->request
->setContentType('text/xml');
59 * @param string $method RPC method name
60 * @param array $params RPC method arguments
61 * @return mixed decoded RPC response
64 public function __call($method, array $params)
66 if ($this->namespace) {
67 $method = $this->namespace .'.'. $method;
70 $data = xmlrpc_encode_request($method, $params);
71 $this->request
->setRawPostData($data);
73 $response = $this->request
->send();
74 if ($response->getResponseCode() != 200) {
76 $response->getResponseStatus(),
77 $response->getResponseCode()
80 $data = xmlrpc_decode($response->getBody(), 'utf-8');
82 if (isset($data['faultCode'], $data['faultString'])) {
92 public function __set($what, $params)
94 return call_user_func_array(
95 array($this->request
, "set$what"),
100 public function __get($what)
102 return call_user_func(
103 array($this->request
, "get$what")