13.09.2016 Views

PHP and MySQL Web Development 4th Ed-tqw-_darksiderg

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Solution Overview<br />

833<br />

Listing 33.8<br />

Continued<br />

}<br />

$this->products[0] = new Product($result['Items']['Item']);<br />

$this->totalResults=1;<br />

unset($soapclient);<br />

unset($soap_proxy);<br />

} else {<br />

// form URL <strong>and</strong> call parseXML to download <strong>and</strong> parse it<br />

$this->url = "http://ecs.amazonaws.com/onca/xml?".<br />

"Service=".$this->Service.<br />

"&Operation=".$this->Operation.<br />

"&AssociateTag=".$this->AssociateTag.<br />

"&AWSAccessKeyId=".$this->AWSAccessKeyId.<br />

"&ResponseGroup=".$this->ResponseGroup.<br />

"&IdType=".$this->IdType.<br />

"&ItemId=".$this->ItemId;<br />

$this->parseXML();<br />

}<br />

return $this->products[0];<br />

}<br />

// Perform a query to get a page full of products with a keyword search<br />

// Switch between XML/HTTP <strong>and</strong> SOAP in index.php<br />

// Returns an array of Products<br />

function keywordSearch($search, $page, $mode = 'Books') {<br />

$this->Service = "AWSECommerceService";<br />

$this->Operation = "ItemSearch";<br />

$this->AWSAccessKeyId = DEVTAG;<br />

$this->AssociateTag = ASSOCIATEID;<br />

$this->ResponseGroup = "Large";<br />

$this->SearchIndex= $mode;<br />

$this->Keywords= $search;<br />

if(METHOD=='SOAP') {<br />

$soapclient = new nusoap_client(<br />

'http://ecs.amazonaws.com/AWSECommerceService/AWSECommerceService.wsdl',<br />

'wsdl');<br />

$soap_proxy = $soapclient->getProxy();<br />

$request = array ('Service' => $this->Service, 'Operation' =><br />

$this->Operation, 'ResponseGroup' => $this->ResponseGroup,

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!