blob: 2fe07c49def0094ef4ffed3a30973dc5278b9a42 [file] [log] [blame]
Derek Jones8ede1a22011-10-05 13:34:52 -05001##################################
2XML-RPC and XML-RPC Server Classes
3##################################
4
5CodeIgniter's XML-RPC classes permit you to send requests to another
6server, or set up your own XML-RPC server to receive requests.
7
Andrey Andreevd8afb982013-09-23 16:01:46 +03008.. contents::
Andrey Andreevcc042092014-01-03 17:08:27 +02009 :local:
Andrey Andreevd8afb982013-09-23 16:01:46 +030010
11.. raw:: html
12
Andrey Andreevcc042092014-01-03 17:08:27 +020013 <div class="custom-index container"></div>
Andrey Andreevd8afb982013-09-23 16:01:46 +030014
Derek Jones8ede1a22011-10-05 13:34:52 -050015****************
16What is XML-RPC?
17****************
18
19Quite simply it is a way for two computers to communicate over the
20internet using XML. One computer, which we will call the client, sends
21an XML-RPC **request** to another computer, which we will call the
22server. Once the server receives and processes the request it will send
23back a **response** to the client.
24
25For example, using the MetaWeblog API, an XML-RPC Client (usually a
26desktop publishing tool) will send a request to an XML-RPC Server
27running on your site. This request might be a new weblog entry being
28sent for publication, or it could be a request for an existing entry for
29editing. When the XML-RPC Server receives this request it will examine
30it to determine which class/method should be called to process the
31request. Once processed, the server will then send back a response
32message.
33
Andrey Andreevd8afb982013-09-23 16:01:46 +030034For detailed specifications, you can visit the `XML-RPC <http://www.xmlrpc.com/>`_ site.
35
36***********************
37Using the XML-RPC Class
38***********************
Derek Jones8ede1a22011-10-05 13:34:52 -050039
40Initializing the Class
41======================
42
43Like most other classes in CodeIgniter, the XML-RPC and XML-RPCS classes
44are initialized in your controller using the $this->load->library
45function:
46
47To load the XML-RPC class you will use::
48
49 $this->load->library('xmlrpc');
50
51Once loaded, the xml-rpc library object will be available using:
52$this->xmlrpc
53
54To load the XML-RPC Server class you will use::
55
Derek Jones92763a52011-10-05 15:28:52 -050056 $this->load->library('xmlrpc');
57 $this->load->library('xmlrpcs');
Derek Jones8ede1a22011-10-05 13:34:52 -050058
59Once loaded, the xml-rpcs library object will be available using:
60$this->xmlrpcs
61
62.. note:: When using the XML-RPC Server class you must load BOTH the
63 XML-RPC class and the XML-RPC Server class.
64
65Sending XML-RPC Requests
66========================
67
68To send a request to an XML-RPC server you must specify the following
69information:
70
71- The URL of the server
72- The method on the server you wish to call
73- The *request* data (explained below).
74
75Here is a basic example that sends a simple Weblogs.com ping to the
76`Ping-o-Matic <http://pingomatic.com/>`_
77
78::
79
Derek Jones92763a52011-10-05 15:28:52 -050080 $this->load->library('xmlrpc');
81
82 $this->xmlrpc->server('http://rpc.pingomatic.com/', 80);
83 $this->xmlrpc->method('weblogUpdates.ping');
84
85 $request = array('My Photoblog', 'http://www.my-site.com/photoblog/');
86 $this->xmlrpc->request($request);
87
88 if ( ! $this->xmlrpc->send_request())
89 {
Andrey Andreevdb6f5f12014-05-16 11:05:16 +030090 echo $this->xmlrpc->display_error();
Derek Jones92763a52011-10-05 15:28:52 -050091 }
Derek Jones8ede1a22011-10-05 13:34:52 -050092
93Explanation
94-----------
95
96The above code initializes the XML-RPC class, sets the server URL and
97method to be called (weblogUpdates.ping). The request (in this case, the
98title and URL of your site) is placed into an array for transportation,
99and compiled using the request() function. Lastly, the full request is
100sent. If the send_request() method returns false we will display the
101error message sent back from the XML-RPC Server.
102
103Anatomy of a Request
104====================
105
106An XML-RPC request is simply the data you are sending to the XML-RPC
107server. Each piece of data in a request is referred to as a request
108parameter. The above example has two parameters: The URL and title of
109your site. When the XML-RPC server receives your request, it will look
110for parameters it requires.
111
112Request parameters must be placed into an array for transportation, and
113each parameter can be one of seven data types (strings, numbers, dates,
114etc.). If your parameters are something other than strings you will have
115to include the data type in the request array.
116
117Here is an example of a simple array with three parameters::
118
Derek Jones92763a52011-10-05 15:28:52 -0500119 $request = array('John', 'Doe', 'www.some-site.com');
120 $this->xmlrpc->request($request);
Derek Jones8ede1a22011-10-05 13:34:52 -0500121
122If you use data types other than strings, or if you have several
123different data types, you will place each parameter into its own array,
124with the data type in the second position::
125
Andrey Andreev053d5d62014-02-11 21:45:39 +0200126 $request = array(
127 array('John', 'string'),
128 array('Doe', 'string'),
129 array(FALSE, 'boolean'),
130 array(12345, 'int')
131 );
Derek Jones92763a52011-10-05 15:28:52 -0500132 $this->xmlrpc->request($request);
Derek Jones8ede1a22011-10-05 13:34:52 -0500133
134The `Data Types <#datatypes>`_ section below has a full list of data
135types.
Andrey Andreevd8afb982013-09-23 16:01:46 +0300136
Derek Jones8ede1a22011-10-05 13:34:52 -0500137Creating an XML-RPC Server
138==========================
139
140An XML-RPC Server acts as a traffic cop of sorts, waiting for incoming
141requests and redirecting them to the appropriate functions for
142processing.
143
144To create your own XML-RPC server involves initializing the XML-RPC
145Server class in your controller where you expect the incoming request to
146appear, then setting up an array with mapping instructions so that
147incoming requests can be sent to the appropriate class and method for
148processing.
149
150Here is an example to illustrate::
151
Derek Jones92763a52011-10-05 15:28:52 -0500152 $this->load->library('xmlrpc');
153 $this->load->library('xmlrpcs');
154
Andrey Andreevdb6f5f12014-05-16 11:05:16 +0300155 $config['functions']['new_post'] = array('function' => 'My_blog.new_entry');
Derek Jones92763a52011-10-05 15:28:52 -0500156 $config['functions']['update_post'] = array('function' => 'My_blog.update_entry');
157 $config['object'] = $this;
158
159 $this->xmlrpcs->initialize($config);
160 $this->xmlrpcs->serve();
Derek Jones8ede1a22011-10-05 13:34:52 -0500161
162The above example contains an array specifying two method requests that
163the Server allows. The allowed methods are on the left side of the
164array. When either of those are received, they will be mapped to the
165class and method on the right.
166
167The 'object' key is a special key that you pass an instantiated class
168object with, which is necessary when the method you are mapping to is
169not part of the CodeIgniter super object.
170
171In other words, if an XML-RPC Client sends a request for the new_post
172method, your server will load the My_blog class and call the new_entry
173function. If the request is for the update_post method, your server
Andrey Andreev053d5d62014-02-11 21:45:39 +0200174will load the My_blog class and call the ``update_entry()`` method.
Derek Jones8ede1a22011-10-05 13:34:52 -0500175
176The function names in the above example are arbitrary. You'll decide
177what they should be called on your server, or if you are using
178standardized APIs, like the Blogger or MetaWeblog API, you'll use their
179function names.
180
181There are two additional configuration keys you may make use of when
182initializing the server class: debug can be set to TRUE in order to
183enable debugging, and xss_clean may be set to FALSE to prevent sending
Andrey Andreev053d5d62014-02-11 21:45:39 +0200184data through the Security library's ``xss_clean()`` method.
Derek Jones8ede1a22011-10-05 13:34:52 -0500185
186Processing Server Requests
187==========================
188
189When the XML-RPC Server receives a request and loads the class/method
190for processing, it will pass an object to that method containing the
191data sent by the client.
192
193Using the above example, if the new_post method is requested, the
194server will expect a class to exist with this prototype::
195
Derek Jones92763a52011-10-05 15:28:52 -0500196 class My_blog extends CI_Controller {
197
Andrey Andreevd8e1ac72012-03-26 22:22:37 +0300198 public function new_post($request)
199 {
Derek Jones92763a52011-10-05 15:28:52 -0500200
Andrey Andreevd8e1ac72012-03-26 22:22:37 +0300201 }
Derek Jones92763a52011-10-05 15:28:52 -0500202 }
Derek Jones8ede1a22011-10-05 13:34:52 -0500203
204The $request variable is an object compiled by the Server, which
205contains the data sent by the XML-RPC Client. Using this object you will
206have access to the *request parameters* enabling you to process the
207request. When you are done you will send a Response back to the Client.
208
209Below is a real-world example, using the Blogger API. One of the methods
Andrey Andreev053d5d62014-02-11 21:45:39 +0200210in the Blogger API is ``getUserInfo()``. Using this method, an XML-RPC
Derek Jones8ede1a22011-10-05 13:34:52 -0500211Client can send the Server a username and password, in return the Server
212sends back information about that particular user (nickname, user ID,
213email address, etc.). Here is how the processing function might look::
214
Derek Jones92763a52011-10-05 15:28:52 -0500215 class My_blog extends CI_Controller {
216
Andrey Andreev053d5d62014-02-11 21:45:39 +0200217 public function getUserInfo($request)
218 {
219 $username = 'smitty';
220 $password = 'secretsmittypass';
Derek Jones92763a52011-10-05 15:28:52 -0500221
Andrey Andreev053d5d62014-02-11 21:45:39 +0200222 $this->load->library('xmlrpc');
Derek Jones92763a52011-10-05 15:28:52 -0500223
Andrey Andreev053d5d62014-02-11 21:45:39 +0200224 $parameters = $request->output_parameters();
Derek Jones92763a52011-10-05 15:28:52 -0500225
Andrey Andreev053d5d62014-02-11 21:45:39 +0200226 if ($parameters[1] != $username && $parameters[2] != $password)
227 {
228 return $this->xmlrpc->send_error_message('100', 'Invalid Access');
229 }
Derek Jones92763a52011-10-05 15:28:52 -0500230
Andrey Andreev053d5d62014-02-11 21:45:39 +0200231 $response = array(
232 array(
233 'nickname' => array('Smitty', 'string'),
234 'userid' => array('99', 'string'),
235 'url' => array('http://yoursite.com', 'string'),
236 'email' => array('jsmith@yoursite.com', 'string'),
237 'lastname' => array('Smith', 'string'),
238 'firstname' => array('John', 'string')
239 ),
240 'struct'
241 );
Derek Jones92763a52011-10-05 15:28:52 -0500242
Andrey Andreev053d5d62014-02-11 21:45:39 +0200243 return $this->xmlrpc->send_response($response);
244 }
Derek Jones92763a52011-10-05 15:28:52 -0500245 }
Derek Jones8ede1a22011-10-05 13:34:52 -0500246
247Notes:
248------
249
Andrey Andreev053d5d62014-02-11 21:45:39 +0200250The ``output_parameters()`` method retrieves an indexed array
Derek Jones8ede1a22011-10-05 13:34:52 -0500251corresponding to the request parameters sent by the client. In the above
252example, the output parameters will be the username and password.
253
254If the username and password sent by the client were not valid, and
Andrey Andreev053d5d62014-02-11 21:45:39 +0200255error message is returned using ``send_error_message()``.
Derek Jones8ede1a22011-10-05 13:34:52 -0500256
257If the operation was successful, the client will be sent back a response
258array containing the user's info.
259
260Formatting a Response
261=====================
262
263Similar to *Requests*, *Responses* must be formatted as an array.
264However, unlike requests, a response is an array **that contains a
265single item**. This item can be an array with several additional arrays,
266but there can be only one primary array index. In other words, the basic
267prototype is this::
268
Andrey Andreev053d5d62014-02-11 21:45:39 +0200269 $response = array('Response data', 'array');
Derek Jones8ede1a22011-10-05 13:34:52 -0500270
271Responses, however, usually contain multiple pieces of information. In
272order to accomplish this we must put the response into its own array so
273that the primary array continues to contain a single piece of data.
274Here's an example showing how this might be accomplished::
275
Andrey Andreev053d5d62014-02-11 21:45:39 +0200276 $response = array(
277 array(
278 'first_name' => array('John', 'string'),
279 'last_name' => array('Doe', 'string'),
280 'member_id' => array(123435, 'int'),
281 'todo_list' => array(array('clean house', 'call mom', 'water plants'), 'array'),
282 ),
283 'struct'
284 );
Derek Jones8ede1a22011-10-05 13:34:52 -0500285
286Notice that the above array is formatted as a struct. This is the most
287common data type for responses.
288
289As with Requests, a response can be one of the seven data types listed
290in the `Data Types <#datatypes>`_ section.
291
292Sending an Error Response
293=========================
294
295If you need to send the client an error response you will use the
296following::
297
298 return $this->xmlrpc->send_error_message('123', 'Requested data not available');
299
300The first parameter is the error number while the second parameter is
301the error message.
302
303Creating Your Own Client and Server
304===================================
305
306To help you understand everything we've covered thus far, let's create a
307couple controllers that act as XML-RPC Client and Server. You'll use the
308Client to send a request to the Server and receive a response.
309
310The Client
311----------
312
Andrey Andreev20292312013-07-22 14:29:10 +0300313Using a text editor, create a controller called Xmlrpc_client.php. In
Alan Jenkinsa51f8ec2012-11-19 10:29:52 +0000314it, place this code and save it to your application/controllers/
Derek Jones92763a52011-10-05 15:28:52 -0500315folder::
Derek Jones8ede1a22011-10-05 13:34:52 -0500316
Derek Jones92763a52011-10-05 15:28:52 -0500317 <?php
Derek Jones8ede1a22011-10-05 13:34:52 -0500318
Derek Jones92763a52011-10-05 15:28:52 -0500319 class Xmlrpc_client extends CI_Controller {
Derek Jones8ede1a22011-10-05 13:34:52 -0500320
Andrey Andreevd8e1ac72012-03-26 22:22:37 +0300321 public function index()
Derek Jones92763a52011-10-05 15:28:52 -0500322 {
323 $this->load->helper('url');
324 $server_url = site_url('xmlrpc_server');
325
326 $this->load->library('xmlrpc');
327
328 $this->xmlrpc->server($server_url, 80);
329 $this->xmlrpc->method('Greetings');
330
331 $request = array('How is it going?');
332 $this->xmlrpc->request($request);
333
334 if ( ! $this->xmlrpc->send_request())
335 {
336 echo $this->xmlrpc->display_error();
337 }
338 else
339 {
340 echo '<pre>';
341 print_r($this->xmlrpc->display_response());
342 echo '</pre>';
343 }
344 }
345 }
346 ?>
347
348.. note:: In the above code we are using a "url helper". You can find more
349 information in the :doc:`Helpers Functions <../general/helpers>` page.
Derek Jones8ede1a22011-10-05 13:34:52 -0500350
351The Server
352----------
353
Andrey Andreev20292312013-07-22 14:29:10 +0300354Using a text editor, create a controller called Xmlrpc_server.php. In
Alan Jenkinsa51f8ec2012-11-19 10:29:52 +0000355it, place this code and save it to your application/controllers/
Derek Jones92763a52011-10-05 15:28:52 -0500356folder::
Derek Jones8ede1a22011-10-05 13:34:52 -0500357
Derek Jones92763a52011-10-05 15:28:52 -0500358 <?php
359
360 class Xmlrpc_server extends CI_Controller {
361
Andrey Andreevd8e1ac72012-03-26 22:22:37 +0300362 public function index()
Derek Jones92763a52011-10-05 15:28:52 -0500363 {
364 $this->load->library('xmlrpc');
365 $this->load->library('xmlrpcs');
366
367 $config['functions']['Greetings'] = array('function' => 'Xmlrpc_server.process');
368
369 $this->xmlrpcs->initialize($config);
370 $this->xmlrpcs->serve();
371 }
372
373
Andrey Andreevd8e1ac72012-03-26 22:22:37 +0300374 public function process($request)
Derek Jones92763a52011-10-05 15:28:52 -0500375 {
376 $parameters = $request->output_parameters();
377
378 $response = array(
Andrey Andreev053d5d62014-02-11 21:45:39 +0200379 array(
380 'you_said' => $parameters[0],
381 'i_respond' => 'Not bad at all.'
382 ),
383 'struct'
384 );
Derek Jones92763a52011-10-05 15:28:52 -0500385
386 return $this->xmlrpc->send_response($response);
387 }
388 }
Derek Jones92763a52011-10-05 15:28:52 -0500389
390
Derek Jones8ede1a22011-10-05 13:34:52 -0500391Try it!
392-------
393
394Now visit the your site using a URL similar to this::
395
396 example.com/index.php/xmlrpc_client/
397
398You should now see the message you sent to the server, and its response
399back to you.
400
401The client you created sends a message ("How's is going?") to the
402server, along with a request for the "Greetings" method. The Server
Andrey Andreev053d5d62014-02-11 21:45:39 +0200403receives the request and maps it to the ``process()`` method, where a
Derek Jones8ede1a22011-10-05 13:34:52 -0500404response is sent back.
405
406Using Associative Arrays In a Request Parameter
407===============================================
408
409If you wish to use an associative array in your method parameters you
410will need to use a struct datatype::
411
Derek Jones92763a52011-10-05 15:28:52 -0500412 $request = array(
Andrey Andreev053d5d62014-02-11 21:45:39 +0200413 array(
414 // Param 0
415 array('name' => 'John'),
416 'struct'
417 ),
418 array(
419 // Param 1
420 array(
421 'size' => 'large',
422 'shape'=>'round'
423 ),
424 'struct'
425 )
426 );
427
Derek Jones92763a52011-10-05 15:28:52 -0500428 $this->xmlrpc->request($request);
Derek Jones8ede1a22011-10-05 13:34:52 -0500429
430You can retrieve the associative array when processing the request in
431the Server.
432
433::
434
Derek Jones92763a52011-10-05 15:28:52 -0500435 $parameters = $request->output_parameters();
Andrey Andreevd8e1ac72012-03-26 22:22:37 +0300436 $name = $parameters[0]['name'];
437 $size = $parameters[1]['size'];
Michael Zimmerd6b7cde2013-06-20 11:54:07 +0200438 $shape = $parameters[1]['shape'];
Derek Jones8ede1a22011-10-05 13:34:52 -0500439
Derek Jones8ede1a22011-10-05 13:34:52 -0500440Data Types
441==========
442
443According to the `XML-RPC spec <http://www.xmlrpc.com/spec>`_ there are
444seven types of values that you can send via XML-RPC:
445
446- *int* or *i4*
447- *boolean*
448- *string*
449- *double*
450- *dateTime.iso8601*
451- *base64*
452- *struct* (contains array of values)
453- *array* (contains array of values)
454
Andrey Andreevd8afb982013-09-23 16:01:46 +0300455***************
456Class Reference
457***************
458
Andrey Andreevcd3d9db2015-02-02 13:41:01 +0200459.. php:class:: CI_Xmlrpc
Andrey Andreevd8afb982013-09-23 16:01:46 +0300460
Andrey Andreevcd3d9db2015-02-02 13:41:01 +0200461 .. php:method:: initialize([$config = array()])
Andrey Andreevd8afb982013-09-23 16:01:46 +0300462
Andrey Andreev28c2c972014-02-08 04:27:48 +0200463 :param array $config: Configuration data
464 :rtype: void
Andrey Andreevd8afb982013-09-23 16:01:46 +0300465
466 Initializes the XML-RPC library. Accepts an associative array containing your settings.
467
Andrey Andreevcd3d9db2015-02-02 13:41:01 +0200468 .. php:method:: server($url[, $port = 80[, $proxy = FALSE[, $proxy_port = 8080]]])
Andrey Andreevd8afb982013-09-23 16:01:46 +0300469
Andrey Andreev28c2c972014-02-08 04:27:48 +0200470 :param string $url: XML-RPC server URL
471 :param int $port: Server port
472 :param string $proxy: Optional proxy
473 :param int $proxy_port: Proxy listening port
474 :rtype: void
Andrey Andreevd8afb982013-09-23 16:01:46 +0300475
476 Sets the URL and port number of the server to which a request is to be sent::
477
478 $this->xmlrpc->server('http://www.sometimes.com/pings.php', 80);
479
Andrey Andreevd1929532014-01-07 12:16:16 +0200480 Basic HTTP authentication is also supported, simply add it to the server URL::
481
482 $this->xmlrpc->server('http://user:pass@localhost/', 80);
483
Andrey Andreevcd3d9db2015-02-02 13:41:01 +0200484 .. php:method:: timeout($seconds = 5)
Andrey Andreevd8afb982013-09-23 16:01:46 +0300485
Andrey Andreev28c2c972014-02-08 04:27:48 +0200486 :param int $seconds: Timeout in seconds
487 :rtype: void
Andrey Andreevd8afb982013-09-23 16:01:46 +0300488
489 Set a time out period (in seconds) after which the request will be canceled::
490
491 $this->xmlrpc->timeout(6);
492
Instructor, Computer Systems Technologya09ffbc2016-10-18 15:28:05 -0700493 This timeout period will be used both for an initial connection to
494 the remote server, as well as for getting a response from it.
Andrey Andreevdc44b922016-10-20 11:56:20 +0300495 Make sure you set the timeout before calling ``send_request()``.
Instructor, Computer Systems Technologya09ffbc2016-10-18 15:28:05 -0700496
Andrey Andreevcd3d9db2015-02-02 13:41:01 +0200497 .. php:method:: method($function)
Andrey Andreevd8afb982013-09-23 16:01:46 +0300498
Andrey Andreev28c2c972014-02-08 04:27:48 +0200499 :param string $function: Method name
500 :rtype: void
Andrey Andreevd8afb982013-09-23 16:01:46 +0300501
502 Sets the method that will be requested from the XML-RPC server::
503
504 $this->xmlrpc->method('method');
505
506 Where method is the name of the method.
507
Andrey Andreevcd3d9db2015-02-02 13:41:01 +0200508 .. php:method:: request($incoming)
Andrey Andreevd8afb982013-09-23 16:01:46 +0300509
Andrey Andreev28c2c972014-02-08 04:27:48 +0200510 :param array $incoming: Request data
511 :rtype: void
Andrey Andreevd8afb982013-09-23 16:01:46 +0300512
513 Takes an array of data and builds request to be sent to XML-RPC server::
514
515 $request = array(array('My Photoblog', 'string'), 'http://www.yoursite.com/photoblog/');
516 $this->xmlrpc->request($request);
517
Andrey Andreevcd3d9db2015-02-02 13:41:01 +0200518 .. php:method:: send_request()
Andrey Andreevd8afb982013-09-23 16:01:46 +0300519
Andrey Andreev28c2c972014-02-08 04:27:48 +0200520 :returns: TRUE on success, FALSE on failure
521 :rtype: bool
Andrey Andreevd8afb982013-09-23 16:01:46 +0300522
523 The request sending method. Returns boolean TRUE or FALSE based on success for failure, enabling it to be used conditionally.
524
525 .. method set_debug($flag = TRUE)
526
Andrey Andreev28c2c972014-02-08 04:27:48 +0200527 :param bool $flag: Debug status flag
528 :rtype: void
Andrey Andreevd8afb982013-09-23 16:01:46 +0300529
Andrey Andreevdb6f5f12014-05-16 11:05:16 +0300530 Enables or disables debugging, which will display a variety of information and error data helpful during development.
Andrey Andreevd8afb982013-09-23 16:01:46 +0300531
Andrey Andreevcd3d9db2015-02-02 13:41:01 +0200532 .. php:method:: display_error()
Andrey Andreevd8afb982013-09-23 16:01:46 +0300533
Andrey Andreev28c2c972014-02-08 04:27:48 +0200534 :returns: Error message string
535 :rtype: string
Andrey Andreevd8afb982013-09-23 16:01:46 +0300536
537 Returns an error message as a string if your request failed for some reason.
538 ::
539
540 echo $this->xmlrpc->display_error();
541
Andrey Andreevcd3d9db2015-02-02 13:41:01 +0200542 .. php:method:: display_response()
Andrey Andreevd8afb982013-09-23 16:01:46 +0300543
Andrey Andreev28c2c972014-02-08 04:27:48 +0200544 :returns: Response
545 :rtype: mixed
Andrey Andreevd8afb982013-09-23 16:01:46 +0300546
547 Returns the response from the remote server once request is received. The response will typically be an associative array.
548 ::
549
550 $this->xmlrpc->display_response();
551
Andrey Andreevcd3d9db2015-02-02 13:41:01 +0200552 .. php:method:: send_error_message($number, $message)
Andrey Andreevd8afb982013-09-23 16:01:46 +0300553
Andrey Andreev28c2c972014-02-08 04:27:48 +0200554 :param int $number: Error number
555 :param string $message: Error message
556 :returns: XML_RPC_Response instance
557 :rtype: XML_RPC_Response
Andrey Andreevd8afb982013-09-23 16:01:46 +0300558
559 This method lets you send an error message from your server to the client.
560 First parameter is the error number while the second parameter is the error message.
561 ::
562
Connor Tumbleson75b3fb22014-01-11 06:58:43 -0600563 return $this->xmlrpc->send_error_message(123, 'Requested data not available');
Andrey Andreevd8afb982013-09-23 16:01:46 +0300564
565 .. method send_response($response)
566
Andrey Andreev28c2c972014-02-08 04:27:48 +0200567 :param array $response: Response data
568 :returns: XML_RPC_Response instance
569 :rtype: XML_RPC_Response
Andrey Andreevd8afb982013-09-23 16:01:46 +0300570
571 Lets you send the response from your server to the client. An array of valid data values must be sent with this method.
572 ::
573
574 $response = array(
575 array(
576 'flerror' => array(FALSE, 'boolean'),
577 'message' => "Thanks for the ping!"
578 ),
579 'struct'
580 );
581
Andrey Andreevdc44b922016-10-20 11:56:20 +0300582 return $this->xmlrpc->send_response($response);