Figure 11.7 shows the XML
formatted results of some example GET requests to the resources http://places/rest/?method=getPlace&id=6
(on the left) and http://places/rest/?method=getReviews&id=6 (on the right) using Firefox.
Figure 11.7 The results of our REST server query; getPlace on the left and getReviews on the right
All our mashup site needs to do is use Zend_Rest_Client to make requests like the following:
$client = new Zend_Rest_Client('http://places/rest/?method=getPlace');
$response = $client->id('6')->get();
Which will return a Zend_Rest_Client_Result object that allows us to access the elements of the response
as properties that can be used in our site like so:
echo $response->name; // Outputs ???Edinburgh Zoo???
Having worked through the implementation of Zend_XmlRpc_Server, itself relatively simple when
compared to say SOAP, you will hopefully have found Zend_Rest_Server very easy to follow. As with any
brief introduction there is a lot that has been left untouched such as PUT and DELETE HTTP requests which
are not handled by Zend_Rest_Server and authentication for example. However, what we have set-up is a
REST server whose strength lies in the relationship between Zend_Rest_Server and Zend_Rest_Client and the
simplicity of implementation.
Pages:
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339