note 72001 added to function.xmlrpc-server-call-method

From: Date: Thu, 28 Dec 2006 16:15:24 +0000
Subject: note 72001 added to function.xmlrpc-server-call-method
Groups: php.notes 
Request: Send a blank email to php-notes+get-120982@lists.php.net to get a copy of this message
xmlrpc_server_call_method() with class methods <?php require_once ('Connections/adodb_mysql_connection.php'); // Instantiating my own class $my_report = new external_report($db_connection); // Setting up the XML-RPC "server" $xmlrpc_server_handler = xmlrpc_server_create(); xmlrpc_server_register_method($xmlrpc_server_handler, "external_method", array(&$my_report, "export")); // Creating XML return data if ($response = xmlrpc_server_call_method($xmlrpc_server_handler, $HTTP_RAW_POST_DATA, null)) { header('Content-Type: text/xml'); echo $response; } // **************** class definition **************** class external_report { protected $db_connection; public function __construct($db_connection_pointer) { if (method_exists($db_connection_pointer, "Execute")) $this->db_connection = $db_connection_pointer; else die("..."); } public function export($method_name, $params_array) { $id_dir = (int)$params_array[0]; $id_usr = (int)$params_array[1]; // not used, just an example // We have to add arguments' validating code here and NOT inside the constructor (as usual) // because arguments are passed directly by xmlrpc_server_call_method (?!!) $myexport = array(); $dirs_query = "SELECT documento_id FROM tabella_cartelle WHERE cartella_id = ".$id_dir; $dirs_result = $this->db_connection->Execute($dirs_query) or die("..."); $index = 0; while(!$dirs_result->EOF) { $docs_query = "SELECT codice, titolo FROM tabella_documenti WHERE id_documento = ".$dirs_result->Fields('documento_id'); $docs_result = $this->db_connection->Execute($docs_query) or die("..."); $myexport[$index]['codice'] = $docs_result->Fields('codice'); $myexport[$index]['titolo'] = $docs_result->Fields('titolo'); $index++; $dirs_result->MoveNext(); } return $myexport; } } ?> ---- Server IP: 213.92.11.19 Probable Submitter: 80.67.115.40 ---- Manual Page -- http://www.php.net/manual/en/function.xmlrpc-server-call-method.php Edit -- https://master.php.net/note/edit/72001 Del: integrated -- https://master.php.net/note/delete/72001/integrated Del: useless -- https://master.php.net/note/delete/72001/useless Del: bad code -- https://master.php.net/note/delete/72001/bad+code Del: spam -- https://master.php.net/note/delete/72001/spam Del: non-english -- https://master.php.net/note/delete/72001/non-english Del: in docs -- https://master.php.net/note/delete/72001/in+docs Del: other reasons-- https://master.php.net/note/delete/72001 Reject -- https://master.php.net/note/reject/72001 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#120982) next »