changeset 3:a5e5475bf357

fix ASIN pblm, add debugging
author robert
date Wed, 28 Dec 2016 12:48:18 +0000
parents 45ae2aeb2b52
children a6b55ae70617
files php/read/getBookDetails.php
diffstat 1 files changed, 32 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/php/read/getBookDetails.php	Wed Dec 28 12:44:57 2016 +0000
+++ b/php/read/getBookDetails.php	Wed Dec 28 12:48:18 2016 +0000
@@ -23,6 +23,7 @@
 	}
 }
 
+global $out,$isbn;
 if(isset($_GET['isbn'])){
 	$isbn = $_GET['isbn'];
 	if(isset($_GET['locale'])){
@@ -172,13 +173,24 @@
 		  $parameters=array(
 			'Operation'       =>$operation              ,
 			'Keywords'        =>urlencode($search)      ,
-			'SearchIndex'     =>$searchindex            ,  //Books for example.
 			"$searchparameter"=>$searchparameterdata    ,
 			'ItemPage'        =>$page                   ,  //which page?
 			'AssociateTag'    =>$Aassociates_id[$locale],
 			'ResponseGroup'   =>'ItemAttributes,Images,SalesRank,BrowseNodes'
 		  );
 
+		  if ($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;
+		  }
+
+
+ file_put_contents('/var/ywww/debug/phpDebug',"parms bd: ".
+		   print_r($parameters,TRUE)."\n",FILE_APPEND);
 
 		$ext=$Aserver[$locale]['ext'];  
 		$file_data=$ext;
@@ -201,8 +213,25 @@
 
 		//echo $out;
 		
+	if (preg_match("<Error>",$out)) {
+	  $xml = new SimpleXMLElement($out);	
+	  $resName=$xml->getName();
+	  $code=$xml->Error->Code;
+	  file_put_contents('/var/ywww/debug/phpDebug',"Losing gBD: $resName, ".
+			    $xml->Error->Code."\n",FILE_APPEND);
+	}
+	else {
 		$xml = new SimpleXMLElement($out);
 		//use this xml to pull out the necessary information and save it
+	set_error_handler(function () {
+	    global $out,$isbn;
+	    file_put_contents('/var/ywww/debug/phpDebug',
+			      "Caught one bd: ".$isbn,
+			      FILE_APPEND);
+	    file_put_contents('/var/ywww/debug/phpDebug',
+			      print_r($out, TRUE)."\n",
+			      FILE_APPEND);
+			      } );
 	
 		$title="";
 		$author="";
@@ -223,7 +252,7 @@
 		$salesRank = $xml->Items->Item->SalesRank;
 		$pubDate = $xml->Items->Item->ItemAttributes->PublicationDate;
 		$publisher = $xml->Items->Item->ItemAttributes->Publisher;
-		
+	restore_error_handler();
 		/*echo $title;
 		echo $author;
 		echo $binding;
@@ -314,5 +343,6 @@
 	$output .=  "</BookDetails>";
 	
 	echo $output;
+	}
 }
 ?>