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.

830 Chapter 33 Connecting to <strong>Web</strong> Services with XML <strong>and</strong> SOAP<br />

Listing 33.8<br />

Continued<br />

}<br />

return $this->products;<br />

function totalResults() {<br />

return $this->totalResults;<br />

}<br />

function getProduct($i) {<br />

if(isset($this->products[$i])) {<br />

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

} else {<br />

return false;<br />

}<br />

}<br />

// Perform a query to get a page full of products from a browse node<br />

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

// Returns an array of Products<br />

function browseNodeSearch($browseNode, $page, $mode) {<br />

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

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

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

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

$this->BrowseNode = $browseNode;<br />

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

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

$this->Sort= 'salesrank';<br />

$this->TotalPages= $page;<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,<br />

'Operation' => $this->Operation, 'BrowseNode' => $this->BrowseNode,<br />

'ResponseGroup' => $this->ResponseGroup, 'SearchIndex' =><br />

$this->SearchIndex, 'Sort' => $this->Sort, 'TotalPages' =><br />

$this->TotalPages);<br />

$parameters = array('AWSAccessKeyId' => DEVTAG,

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

Saved successfully!

Ooh no, something went wrong!