43 require_once
'XML/RPC2/Exception.php';
44 require_once
'XML/RPC2/Client.php';
128 $this->_postData = $value;
148 if (!preg_match(
'/(https?:\/\/)(.*)/', $uri))
throw new XML_RPC2_Exception(
'Unable to parse URI');
150 if (isset($params[
'encoding'])) {
151 $this->_encoding = $params[
'encoding'];
153 if (isset($params[
'proxy'])) {
154 $proxy = $params[
'proxy'];
155 $elements = parse_url($proxy);
156 if (is_array($elements)) {
157 if ((isset($elements[
'scheme'])) and (isset($elements[
'host']))) {
158 $this->_proxy = $elements[
'scheme'] .
'://' . $elements[
'host'];
160 if (isset($elements[
'port'])) {
161 $this->_proxy = $this->_proxy .
':' . $elements[
'port'];
163 if ((isset($elements[
'user'])) and (isset($elements[
'pass']))) {
164 $this->_proxyAuth = $elements[
'user'] .
':' . $elements[
'pass'];
168 if (isset($params[
'sslverify'])) {
169 $this->_sslverify = $params[
'sslverify'];
184 if (!function_exists(
'curl_init') &&
186 @dl(
'php_curl' . PHP_SHLIB_SUFFIX) || @dl(
'curl' . PHP_SHLIB_SUFFIX)
190 if ($ch = curl_init()) {
192 (is_null($this->_proxy) || curl_setopt($ch, CURLOPT_PROXY, $this->_proxy)) &&
193 (is_null($this->_proxyAuth) || curl_setopt($ch, CURLOPT_PROXYUSERPWD, $this->_proxyAuth)) &&
194 curl_setopt($ch, CURLOPT_URL, $this->_uri) &&
195 curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE) &&
196 curl_setopt($ch, CURLOPT_POST, 1) &&
197 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, $this->_sslverify) &&
198 curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-type: text/xml; charset='.$this->_encoding,
'User-Agent: PEAR_XML_RCP2/' .
XML_RPC2_Client::VERSION)) &&
199 curl_setopt($ch, CURLOPT_POSTFIELDS, $this->_postData)
201 $result = curl_exec($ch);
202 if (($errno = curl_errno($ch)) != 0) {
205 $info = curl_getinfo($ch);
206 if ($info[
'http_code'] != 200) {
215 $this->_body = $result;