function query() { $args = func_get_args(); $method = array_shift($args); $request = new XMLRPC_Request($method, $args); $length = $request->getLength(); $xml = $request->getXml(); $header = "Content-type: text/xml\r\nContent-length: {$length}\r\n"; //choose transport if ($this->httpsWrapperEnabled()) { $opts = array('http' => array('method' => 'POST', 'header' => $header, 'content' => $xml), 'ssl' => array('cafile' => dirname(__FILE__) . '/cacert.pem', 'verify_peer' => true, 'verify_peer_name' => true)); $contents = file_get_contents($this->url, false, stream_context_create($opts)); } else { $ch = curl_init(); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, true); curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_URL, $this->url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: text/xml')); curl_setopt($ch, CURLOPT_POSTFIELDS, $xml); $contents = curl_exec($ch); curl_close($ch); } // Now parse what we've got back $this->message = new XMLRPC_Message($contents); if (!$this->message->parse()) { // XML error $this->error = new XMLRPC_Error(-32700, 'parse error. not well formed'); return false; } // Is the message a fault? if ($this->message->messageType == 'fault') { $this->error = new XMLRPC_Error($this->message->faultCode, $this->message->faultString); return false; } // Message must be OK return true; }