/** * Handle all incoming XMLRPC requests. */ public function act_xmlrpc_call() { if ($_SERVER['REQUEST_METHOD'] != 'POST') { $exception = new XMLRPCException(1); $exception->output_fault_xml(); // dies here } $input = file_get_contents('php://input'); $xml = new \SimpleXMLElement($input); $function = $xml->methodName; $params = array(); $found_params = $xml->xpath('//params/param/value'); if (is_array($found_params)) { foreach ($found_params as $param) { $params[] = XMLRPCUtils::decode_args($param); } } $returnvalue = false; Plugins::register(array($this, 'system_listMethods'), 'xmlrpc', 'system.listMethods'); $returnvalue = Plugins::xmlrpc("{$function}", $returnvalue, $params, $this); $response = new \SimpleXMLElement('<?xml version="1.0"?' . '><methodResponse><params><param></param></params></methodResponse>'); XMLRPCUtils::encode_arg($response->params->param, $returnvalue); ob_end_clean(); header('Content-Type: text/xml;charset=utf-8'); echo trim($response->asXML()); exit; }
public function xmlrpc_blogger__deletePost($params) { // Authentication $user = $this->is_auth($params[2], $params[3]); // Retrieve the post to delete $post = Post::get(array('id' => $params[1])); if (!empty($post)) { // Post exists, try deleting it if ($post->delete()) { return true; } else { // Failed to delete post, no way to know the error yet $exception = new XMLRPCException(812); $exception->output_fault_xml(); } } else { // Post does not exist or failed to retrieve the post $exception = new XMLRPCException(806); $exception->output_fault_xml(); } }