Skip to Content
Amazon Hacks
book

Amazon Hacks

by Paul Bausch
August 2003
Intermediate to advanced
304 pages
7h 33m
English
O'Reilly Media, Inc.
Content preview from Amazon Hacks

Program AWS with NuSOAP and PHP

PHP’s standard SOAP module NuSOAP makes SOAP simple.

Like Perl, PHP has its emerging standard method of working with SOAP applications. NuSOAP is a single PHP script (with over 4,000 lines of code!) that handles all of the SOAP heavy lifting for you. Get your copy from http://dietrich.ganx4.com/nusoap/ and include the file in the same directory as your scripts.

The Code

The script, amazon_soap.php , is meant to be run as a web page. It accepts a variable, keyword, in the URL. With this, it creates the proper SOAP request and returns the results as an array.

<html>
<head>
<title>Amazon Keyword Search</title>
</head>
<body>
<?
#Use the NuSOAP php library
require_once('nusoap.php');

#Set parameters
$parameters = array('keyword' => $HTTP_GET_VARS['keyword'],
    'type' => 'lite',
    'page' => '1',
    'mode' => 'books',
    'tag' => 'insert associate tag',
    'devtag' => 'insert developer token');

#Create a new SOAP client with Amazon's WSDL
$soapclient = new soapclient('http://soap.amazon.com/schemas2/[RETURN] AmazonWebServices.wsdl','wsdl'); $proxy = $soapclient->getproxy( ); #query Amazon $results = $proxy->KeywordSearchRequest($parameters); //echo 'Request: <xmp>'.$proxy->request.'</xmp>'; //echo 'Response: <xmp>'.$proxy->response.'</xmp>'; #Results? if (is_array($results['Details'])) { print "<p>Search for <b>" . $HTTP_GET_VARS['keyword'] . "</b>" . " found " . $results['TotalResults'] . " results." . " <br>Here are the first " . count($results['Details']).".". " </p><ol>"; ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

The Three Traps That Stymie Reinvention

The Three Traps That Stymie Reinvention

Ryan Raffaelli
Voice Application Development with VoiceXML

Voice Application Development with VoiceXML

Rick Beasley, Kenneth Michael Farley, John O'Reilly, Leon Henry Squire
The Human Factor in AI-Based Decision-Making

The Human Factor in AI-Based Decision-Making

Philip Meissner, Christoph Keding
What Successful Project Managers Do

What Successful Project Managers Do

W. Scott Cameron, Jeffrey S. Russell, Edward J. Hoffman, Alexander Laufer

Publisher Resources

ISBN: 0596005423Catalog PageErrata