/** * This is our implementation of the query function from the IXR_Client class so that we can use the * YDHttpClient class to do the HTTP stuff. */ function query() { // Get the function arguments $args = func_get_args(); $method = array_shift($args); // Create a new request $request = new IXR_Request($method, $args); // Create a new HTTP client $client = new YDHttpClient($this->server, $this->port); if (isset($this->timeout)) { $client->setTimeout($this->timeout); } $client->useGzip(true); $client->setDebug(YDConfig::get('YD_DEBUG')); $client->path = $this->path; $client->method = 'POST'; $client->contenttype = 'text/xml'; $client->postdata = str_replace("\n", '', $request->getXml()); $client->handle_redirects = false; // Show in debugging mode if ($this->debug) { $tmp = htmlspecialchars($client->postdata); echo '<pre>' . $tmp . YD_CRLF . '</pre>' . YD_CRLF . YD_CRLF; } // Now send the request $result = $client->doRequest(); // Die with an error if any if (!$result) { $this->error = new IXR_Error(-32300, $client->getError()); return false; } // Get the contents $contents = $client->getContent(); // Show in debugging mode if ($this->debug) { $tmp = htmlspecialchars($contents); echo '<pre>' . $tmp . YD_CRLF . '</pre>' . YD_CRLF . YD_CRLF; } // Now parse what we've got back $this->message = new IXR_Message($contents); if (!$this->message->parse()) { $this->error = new IXR_Error(-32700, 'parse error. not well formed'); return false; } // Is the message a fault? if ($this->message->messageType == 'fault') { $this->error = new IXR_Error($this->message->faultCode, $this->message->faultString); return false; } // Message must be OK return true; }