projects
/
m6w6
/
ext-http
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
|
github
raw
|
patch
|
inline
| side by side (from parent 1:
8164d4e
)
- cleanup
author
Michael Wallner
<mike@php.net>
Wed, 12 Apr 2006 08:50:32 +0000
(08:50 +0000)
committer
Michael Wallner
<mike@php.net>
Wed, 12 Apr 2006 08:50:32 +0000
(08:50 +0000)
lib/XmlRpcClient.php
patch
|
blob
|
history
diff --git
a/lib/XmlRpcClient.php
b/lib/XmlRpcClient.php
index 886198b3662cac58d6a59952acaa686f77432507..9cdc7bbd54151115576e730556f6be20a6fb6496 100644
(file)
--- a/
lib/XmlRpcClient.php
+++ b/
lib/XmlRpcClient.php
@@
-10,6
+10,7
@@
* <code>
* <?php
* $rpc = new XmlRpcClient('http://mike:secret@example.com/cgi-bin/vpop-xmlrpc', 'vpop');
* <code>
* <?php
* $rpc = new XmlRpcClient('http://mike:secret@example.com/cgi-bin/vpop-xmlrpc', 'vpop');
+ * $rpc->options = array(array('compress' => true));
* try {
* print_r($rpc->listdomain(array('domain' => 'example.com')));
* } catch (Exception $ex) {
* try {
* print_r($rpc->listdomain(array('domain' => 'example.com')));
* } catch (Exception $ex) {
@@
-37,7
+38,7
@@
class XmlRpcClient
*
* @var HttpRequest
*/
*
* @var HttpRequest
*/
- p
rotected
$request;
+ p
ublic
$request;
/**
* Constructor
/**
* Constructor
@@
-52,27
+53,6
@@
class XmlRpcClient
$this->request->setContentType('text/xml');
}
$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;
- }
-
/**
* RPC method proxy
*
/**
* RPC method proxy
*
@@
-86,12
+66,42
@@
class XmlRpcClient
if ($this->namespace) {
$method = $this->namespace .'.'. $method;
}
if ($this->namespace) {
$method = $this->namespace .'.'. $method;
}
- $this->request->setRawPostData(xmlrpc_encode_request($method, $params));
+
+ $data = xmlrpc_encode_request($method, $params);
+ $this->request->setRawPostData($data);
+
$response = $this->request->send();
if ($response->getResponseCode() != 200) {
$response = $this->request->send();
if ($response->getResponseCode() != 200) {
- throw new Exception($response->getBody(), $response->getResponseCode());
+ throw new Exception(
+ $response->getResponseStatus(),
+ $response->getResponseCode()
+ );
+ }
+ $data = xmlrpc_decode($response->getBody(), 'utf-8');
+
+ if (isset($data['faultCode'], $data['faultString'])) {
+ throw new Exception(
+ $data['faultString'],
+ $data['faultCode']
+ );
}
}
- return xmlrpc_decode($response->getBody(), 'utf-8');
+
+ return $data;
+ }
+
+ public function __set($what, $params)
+ {
+ return call_user_func_array(
+ array($this->request, "set$what"),
+ $params
+ );
+ }
+
+ public function __get($what)
+ {
+ return call_user_func(
+ array($this->request, "get$what")
+ );
}
}
}
}