PhpRiot
Follow phpriot on Twitter
Sponsored Link
Become Zend Certified

Prepare for the ZCE exam using our quizzes (web or iPad/iPhone). More info...


When you're ready get 7.5% off your exam voucher using voucher CJQNOV23 at the Zend Store
Free iPad/iPhone App
Available on the App Store

  • PHP manual
  • Zend Framework manual
  • Smarty manual
  • PHP articles
  • PHP training

Introduction

Using the Zend_Rest_Client is very similar to using SoapClient objects (SOAP web service extension). You can simply call the REST service procedures as Zend_Rest_Client methods. Specify the service's full address in the Zend_Rest_Client constructor.

Example 677. A basic REST request

<?php
/**
 * Connect to framework.zend.com server and retrieve a greeting
 */
$client = new Zend_Rest_Client('http://framework.zend.com/rest');

echo 
$client->sayHello('Davey''Day')->get(); // "Hello Davey, Good Day"

Differences in calling

Zend_Rest_Client attempts to make remote methods look as much like native methods as possible, the only difference being that you must follow the method call with one of either get(), post(), put() or delete(). This call may be made via method chaining or in separate method calls:

<?php
$client
->sayHello('Davey''Day');
echo 
$client->get();

Zend Framework