changeset 33:c9d9b76ecbf9

minor tidying
author Charlie Root
date Fri, 04 Jan 2019 11:35:59 -0500
parents 8130865e9e82
children 5cae8d572998
files xml/getAmazonInfo.php
diffstat 1 files changed, 11 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/xml/getAmazonInfo.php	Fri Jan 04 09:50:55 2019 -0500
+++ b/xml/getAmazonInfo.php	Fri Jan 04 11:35:59 2019 -0500
@@ -9,7 +9,7 @@
 		  'page'               =>1,              //first page to show (we are counting from 1 not 0)
 		  //'search'             =>'Machiavelli',  //what to search for?
 		  'operation'          =>'ItemLookup',   //what to do?	//ItemSearch
-		  // 'searchindex'        =>'Books',        //what product category for search?
+		  'searchindex'        =>'Books',        //what product category for search?
 		  'searchparameter'    =>'ItemId',       //what kind of search?
 		  'searchparameterdata'=>$isbn,  //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'
@@ -47,7 +47,8 @@
 				$searchparameterdata,
 				$show_array,$show_url,$show_xml);
     }
-    catch (Exception $code) {
+    catch (Exception $e) {
+      $code=$e->getMessage();
       file_put_contents('/var/ywww/debug/phpDebug',
 			"Bang: $code $i\n",FILE_APPEND);
       if ($code=='RequestThrottled') {
@@ -124,7 +125,6 @@
   $parameters=array(
 		    'Operation'       =>$operation              ,
 		    //'Keywords'        =>urlencode($search)      ,
-		    //'SearchIndex'     =>$searchindex            ,  //Books for example.
 		    "$searchparameter"=>$searchparameterdata    ,
 		    'ItemPage'        =>$page                   ,  //which page?
 		    'AssociateTag'    =>$Aassociates_id[$locale],
@@ -132,21 +132,16 @@
 		    'ReviewSort'	  =>'-HelpfulVotes'
 		    );
 
+  if (isset($searchindex) && $searchindex!='Books') {
+    // HST did this
+    // Used to be in $parameters init above, but
+    // that caused an error:
+    // If idType equals ASIN, SearchIndex cannot be present
+    //'SearchIndex'     =>$searchindex      ,  //Books for example.
+    $parameters['SearchIndex']=$searchindex;
+  }
   $requestURI = $_SERVER['REQUEST_URI'];
   $requestIP = $_SERVER['REMOTE_ADDR'];
-  // if ($requestIP=="173.161.113.65" || $requestIP=="141.8.132.25") {
-  // 	    $delay=60;
-  // 	    file_put_contents('/var/ywww/debug/phpDebug',
-  // 			      "bad guy: $requestIP, $requestURI\n",
-  // 			      FILE_APPEND);
-  // 	    sleep($delay);
-  // 	    # No, can't do this
-  // 	    # return; # bomb!
-  // 	    # 'Kung', sitting on my desk in the office while I'm at home,
-  // 	    # is occasionally hitting xml/getAmazonInfo.php:
-  // 	    # e.g. Losing: ItemLookupErrorResponse, RequestThrottled, 129.215.197.36, /xml/getAmazonInfo.php?searchparameterdata=075154454X&locale=uk
-  // 	    # repeatedly, same params
-  // }
   $ext=$Aserver[$locale]['ext'];  
   $file_data=$ext;
   ksort($parameters);