PhpRiot
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

Using the Alternative Query API

Introduction

Zend_Service_Amazon_Query provides an alternative API for using the Amazon Web Service. The alternative API uses the Fluent Interface pattern. That is, all calls can be made using chained method calls. (e.g., $obj->method()->method2($arg))

The Zend_Service_Amazon_Query API uses overloading to easily set up an item search and then allows you to search based upon the criteria specified. Each of the options is provided as a method call, and each method's argument corresponds to the named option's value:

Example 716. Search Amazon Using the Alternative Query API

In this example, the alternative query API is used as a fluent interface to specify options and their respective values:

<?php
$query 
= new Zend_Service_Amazon_Query('MY_API_KEY''US''AMAZON_SECRET_KEY');
$query->Category('Books')->Keywords('PHP');
$results $query->search();
foreach (
$results as $result) {
    echo 
$result->Title '<br />';
}

This sets the option Category to "Books" and Keywords to "PHP".

For more information on the available options, please refer to the relevant Amazon documentation.


Zend Framework