Mercurial > hg > ywww
view xml/amazonBookSearch.php @ 60:05f29eb72283 default tip
review from DB not working???
author | Charlie Root |
---|---|
date | Sun, 09 Jun 2019 06:50:44 -0400 |
parents | a67bf725e87b |
children |
line wrap: on
line source
<?php include_once "dlog.php"; include_once "xml/doAmazonRequest.php"; $Adefault=array( 'language' =>'en', //what language to render the page in 'locale' =>'us', //which server's products? available: ca,de,fr,jp,uk,us 'page' =>1, //first page to show (we are counting from 1 not 0) 'operation' =>'ItemSearch', //what to do? //ItemSearch 'searchindex' =>'Books', //what product category for search? 'searchparameter' =>'Keywords', //what kind of search? 'searchparameterdata'=>'Machiavelli', //what to search for? //here some debugging flags you can put at the end of the URL to call this script with, like: '?show_array=true' 'show_url' =>false, //debug: show XML request url to be send to Amazon? ); //for all parameters see if the user has overruled it or use the default foreach ($Adefault as $i=>$d) { $$i=isset($_GET[$i])?$_GET[$i]:$d; } //this is the data that is used to form the request for AWS //this is the part that is search specific $parameters=array( 'Operation' =>$operation , //'Keywords' =>urlencode($search) , 'SearchIndex' =>$searchindex , //Books for example. "$searchparameter"=>stripslashes($searchparameterdata), 'ItemPage' =>$page , //which page? 'AssociateTag' =>$Aassociates_id[$locale], 'MerchantId' =>'All', 'Availability' =>'Available', 'Condition' =>'All', 'ResponseGroup' =>'Images,ItemAttributes' , //Small, Medium, Large or SellerListing ); try { $ret=doAmazonRequest($Aserver[$locale]['ext'],$parameters,3,'s',False); } catch (Exception $e) { if ($e->getMessage()=='AWS.ECommerceService.NoExactMatches') { // Seems to be an 'OK' thing... $ret='<?xml version="1.0" ?><ItemSearchResponse xmlns="http://webservices.amazon.com/AWSECommerceService/2011-08-01"><OperationRequest><RequestId>0e41c74c-eeff-4f24-a761-9537cfebea21</RequestId></OperationRequest><Items><Request><IsValid>True</IsValid></Request><TotalResults>0</TotalResults><TotalPages>0</TotalPages></Items></ItemSearchResponse>'; } else { $ret='<?xml version="1.0" ?><ItemSearchResponse xmlns="http://webservices.amazon.com/AWSECommerceService/2011-08-01"><OperationRequest><RequestId>0e41c74c-eeff-4f24-a761-9537cfebea21</RequestId></OperationRequest><Items><Request><IsValid>True</IsValid><Errors><Error><Code>'.$code.'</Code><Message>[lost]</Message></Error></Errors></Request><TotalResults>0</TotalResults><TotalPages>0</TotalPages></Items></ItemSearchResponse>'; } } echo $ret;