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.

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

Listing 33.8<br />

Continued<br />

return $product->imageURLLarge();<br />

}<br />

}<br />

// if not found<br />

$this->ASINSearch($ASIN, $mode);<br />

return $this->products(0)->imageURLLarge();<br />

}<br />

// Perform a query to get a products with specified ASIN<br />

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

// Returns a Products object<br />

function ASINSearch($ASIN, $mode = 'books') {<br />

$this->type = 'ASIN';<br />

$this->ASIN=$ASIN;<br />

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

$ASIN = padASIN($ASIN);<br />

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

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

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

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

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

$this->IdType = "ASIN";<br />

$this->ItemId = $ASIN;<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,<br />

'IdType' => $this->IdType, 'ItemId' => $this->ItemId);<br />

$parameters = array('AWSAccessKeyId' => DEVTAG,<br />

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

// perform actual soap query<br />

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

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

return false;

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

Saved successfully!

Ooh no, something went wrong!