com>
Zend Framework in Action (Ch01) Manning Publications Co. 27
of the functionality of Zend_XmlRpc already. In this section we??™ll demonstrate those a little further by
simulating a client request to the editPost() method we demonstrated in listing 11.6 using
Zend_XmlRpc_Client.
Unlike Zend_XmlRpc_Server which was used within its own front controller we are using
Zend_XmlRpc_Client within a controller action as shown in listing 11.8.
Listing 11.8 Zend_XmlRpc_Client used within a controller action
public function editPostAction()
{
$xmlRpcServer = 'http://places/xmlrpc/'; A
$client = new Zend_XmlRpc_Client($xmlRpcServer); B
// Set up filters
$filterInt = new Zend_Filter_Int; C
$filterStripTags = new Zend_Filter_StripTags;
$id = $filterInt->filter($_POST['id']);
$publish = (bool) $_POST['publish'];
$structData = array( D
'title' => $filterStripTags->filter($_POST['title']),
'dateCreated' => new Zend_XmlRpc_Value_DateTime(time(),
Zend_XmlRpc_Value::XMLRPC_TYPE_DATETIME),
'description' => $filterStripTags->filter($_POST['body']
);
$client->call('metaWeblog.editPost',
array($id,'myusername','mypassword', $structData, $publish)); E
}
A Assign the URL of the XML-RPC server that the client will send its requests to
B Instantiate the client object with the server URL
C Filter input from the HTML form
D Setup the data that will become an XML-RPC struct
E Make the remote procedure call with the assembled data
In this example we are filtering the data from an HTML form and preparing it for use by the client that has
been set-up with the URL of the XML-RPC server we will be sending requests to.
Pages:
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328