Source for file amazon_example1.php
Documentation is available at amazon_example1.php
// Example of usage for Services_Amazon
require_once 'config.php';
require_once 'Services/Amazon.php';
echo " <p><i>{$msg}</i><p></body></html>";
// Display previous/next links
echo '<tr><td colspan="2">';
'&page=' . ($page - 1 )) . '">« Previous Page</a> ';
echo 'Page ' . $page . ' of ' . $pages . ' ';
'&page=' . ($page + 1 )) . '">Next Page »</a>';
echo 'This script was written to work with Services_Amazon 1 API';
<meta http-equiv="Content-type" content="text/html; charset=UTF-8" />
<title>Services_Amazon example</title>
<form action="{ $php_self}" method="get">
// $modes = array('baby' => 'Baby',
// 'classical' => 'Classical Music',
foreach($modes as $k => $v) {
echo '<option value="' . $k . ($k == $_GET['mode'] ? '" selected="selected"' : '') . '">' . htmlspecialchars($v) . '</option>';
<td><input type="text" name="keyword" value="{ $keyword}" /></td>
<td><input type="hidden" name="page" value="1" /></td>
<td><input type="submit" value="Search" /></td>
if (empty ($_GET['keyword'])) {
if (!is_numeric($_GET['page']) || $_GET['page'] < 1 ) {
if (!isset ($modes[$_GET['mode']])) {
$products = $amazon->searchKeyword ($_GET['keyword'], $_GET['mode'], $_GET['page']);
if (PEAR ::isError ($products)) {
echo '<table border="0">';
$pages = $products['pages'];
$page = $products['page'];
for($i = 0; $i < 10; $i++ ) {
if (!isset ($products[$i])) break;
$product = $products[$i];
$creator = 'by ' . implode(', ', $product['authors']);
} elseif (is_array($product['artists'])) {
$creator = 'by ' . implode(', ', $product['artists']);
if($product['listprice'] != $product['ourprice']) {
$price = '<strike>' . $product['listprice'] . '</strike> ' . $product['ourprice'];
$price = $product['listprice'];
<td valign="top"><a href="{ $product['url']}"><img src="{ $product['imagesmall']}" border="0" alt="" /></a></td>
<b>{ $product['name']}</b> $creator<br />
Category: { $product['type']}<br />
Release Date: { $product['release']}<br />
Manufacturer: { $product['manufacturer']}<br />
echo '</table></body></html>';
Documentation generated on Mon, 11 Mar 2019 15:46:57 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|