From 4b9c62980599228f070b401c7673dce8085b0c61 Mon Sep 17 00:00:00 2001
From: Derek Jones
Quite simply it is a way for two computers to communicate over the internet using XML. One computer, which we will call the client, sends an XML-RPC request to -another computer, which we will call the server. Once the server receives and processes the request it +another computer, which we will call the server. Once the server receives and processes the request it will send back a response to the client.
For example, using the MetaWeblog API, an XML-RPC Client (usually a desktop publishing tool) will
-send a request to an XML-RPC Server running on your site. This request might be a new weblog entry
+send a request to an XML-RPC Server running on your site. This request might be a new weblog entry
being sent for publication, or it could be a request for an existing entry for editing.
When the XML-RPC Server receives this request it will examine it to determine which class/method should be called to process the request.
@@ -127,16 +127,16 @@ if ( ! $this->xmlrpc->send_request())
The above code initializes the XML-RPC class, sets the server URL and method to be called (weblogUpdates.ping). The +
The above code initializes the XML-RPC class, sets the server URL and method to be called (weblogUpdates.ping). The request (in this case, the title and URL of your site) is placed into an array for transportation, and compiled using the request() function. -Lastly, the full request is sent. If the send_request() method returns false we will display the error message +Lastly, the full request is sent. If the send_request() method returns false we will display the error message sent back from the XML-RPC Server.
An XML-RPC request is simply the data you are sending to the XML-RPC server. Each piece of data in a request -is referred to as a request parameter. The above example has two parameters: +
An XML-RPC request is simply the data you are sending to the XML-RPC server. Each piece of data in a request +is referred to as a request parameter. The above example has two parameters: The URL and title of your site. When the XML-RPC server receives your request, it will look for parameters it requires.
Request parameters must be placed into an array for transportation, and each parameter can be one
@@ -161,7 +161,7 @@ $request = array (
$this->xmlrpc->request($request);
-The Data Types section below has a full list of data types.
+The Data Types section below has a full list of data types.
@@ -198,7 +198,7 @@ server will load the My_blog class and call the new_entry
If the request is for the update_post method, your
server will load the My_blog class and call the update_entry function.
The function names in the above example are arbitrary. You'll decide what they should be called on your server, +
The function names in the above example are arbitrary. You'll decide what they should be called on your server, or if you are using standardized APIs, like the Blogger or MetaWeblog API, you'll use their function names.
There are two additional configuration keys you may make use of when initializing the server class: debug can be set to TRUE in order to enable debugging, and xss_clean may be set to FALSE to prevent sending data through the Security library's xss_clean function. @@ -221,12 +221,12 @@ to exist with this prototype:
The $request variable is an object compiled by the Server, which contains the data sent by the XML-RPC Client. -Using this object you will have access to the request parameters enabling you to process the request. When +Using this object you will have access to the request parameters enabling you to process the request. When you are done you will send a Response back to the Client.
-Below is a real-world example, using the Blogger API. One of the methods in the Blogger API is getUserInfo(). +
Below is a real-world example, using the Blogger API. One of the methods in the Blogger API is getUserInfo(). Using this method, an XML-RPC Client can send the Server a username and password, in return the Server sends -back information about that particular user (nickname, user ID, email address, etc.). Here is how the processing +back information about that particular user (nickname, user ID, email address, etc.). Here is how the processing function might look:
@@ -272,14 +272,14 @@ In the above example, the output parameters will be the username and password.Similar to Requests, Responses must be formatted as an array. However, unlike requests, a response is an array -that contains a single item. This item can be an array with several additional arrays, but there -can be only one primary array index. In other words, the basic prototype is this:
+Similar to Requests, Responses must be formatted as an array. However, unlike requests, a response is an array +that contains a single item. This item can be an array with several additional arrays, but there +can be only one primary array index. In other words, the basic prototype is this:
-$response = array('Response data', 'array');
+$response = array('Response data', 'array');
Responses, however, usually contain multiple pieces of information. In order to accomplish this we must put the response into its own -array so that the primary array continues to contain a single piece of data. Here's an example showing how this might be accomplished:
+array so that the primary array continues to contain a single piece of data. Here's an example showing how this might be accomplished:
$response = array (
@@ -293,9 +293,9 @@ $response = array (
);
-Notice that the above array is formatted as a struct. This is the most common data type for responses.
+Notice that the above array is formatted as a struct. This is the most common data type for responses.
-As with Requests, a response can be one of the seven data types listed in the Data Types section.
+As with Requests, a response can be one of the seven data types listed in the Data Types section.
To help you understand everything we've covered thus far, let's create a couple controllers that act as -XML-RPC Client and Server. You'll use the Client to send a request to the Server and receive a response.
+XML-RPC Client and Server. You'll use the Client to send a request to the Server and receive a response.Note: In the above code we are using a "url helper". You can find more information in the Helpers Functions page.
+Note: In the above code we are using a "url helper". You can find more information in the Helpers Functions page.
The request sending function. Returns boolean TRUE or FALSE based on success for failure, enabling it to be used conditionally.
+The request sending function. Returns boolean TRUE or FALSE based on success for failure, enabling it to be used conditionally.
Enables debugging, which will display a variety of information and error data helpful during development.
@@ -463,7 +463,7 @@ $this->xmlrpc->request($request);echo $this->xmlrpc->display_error();
Returns the response from the remote server once request is received. The response will typically be an associative array.
+Returns the response from the remote server once request is received. The response will typically be an associative array.
$this->xmlrpc->display_response();