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.

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

Listing 33.9<br />

Continued<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,<br />

'AssociateTag' => ASSOCIATEID, 'Request'=>array($request));<br />

// perform actual soap query<br />

$result = $soap_proxy->ItemSearch($parameters);<br />

if(isSOAPError($result)) {<br />

return false;<br />

}<br />

$this->totalResults = $result['TotalResults'];<br />

foreach($result['Items']['Item'] as $product) {<br />

$this->products[] = new Product($product);<br />

}<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 />

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

"&ResponseGroup=".$this->ResponseGroup.

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

Saved successfully!

Ooh no, something went wrong!