diff php/read/getBookDetails.php @ 53:dd93cb4b77ad

more debugging (too much for production), fallback to DB if getBookDetails is knocked back by Amazon
author Charlie Root
date Thu, 06 Jun 2019 16:37:20 -0400
parents a67bf725e87b
children 39600878ff93
line wrap: on
line diff
--- a/php/read/getBookDetails.php	Thu Jun 06 16:33:34 2019 -0400
+++ b/php/read/getBookDetails.php	Thu Jun 06 16:37:20 2019 -0400
@@ -103,7 +103,7 @@
 	else {
 	  mysqli_close($link);	//do not remove. reset is needed otherwise mysqli_fetch_array doesn't work after first loop
 	}
-	
+	dl("gbd: ".strlen($output)." $proceed\n$output\n");
 	if($proceed == true)
 	  {
 	    include "aws_signed_request.php";
@@ -147,7 +147,7 @@
 	    }
 
 	    try {
-	      $xml=doAmazonRequest($Aserver[$locale]['ext'],$parameters,6,'d');
+	      $xml=doAmazonRequest($Aserver[$locale]['ext'],$parameters,2,'d');
 	      //use this xml to pull out the necessary information and save it
 	      set_error_handler(function () {
 		  global $out,$isbn;
@@ -288,6 +288,28 @@
 	    }
 	    catch (Exception $e) {
 	      dl("gBD: dAR failed:".$e->getMessage()."\n");
+	      if (isset($rows)) {
+		dl("gBD:  returning stale info from DB: $timeDiff\n");
+		/* HST hack, copied from above */
+		$output .=  "<ISBN>" . $isbn . "</ISBN>";
+		$output .=  "<Title>" . htmlspecialchars($rows["Title"]) . "</Title>";
+		$output .=  "<Author>" . htmlspecialchars($rows["Author"]) . "</Author>";
+		$output .=  "<Binding>" . htmlspecialchars($rows["Binding"]) . "</Binding>";
+		$output .=  "<Dewey>" . htmlspecialchars($rows["DeweyDecimal"]) . "</Dewey>";
+		$output .=  "<ImageURL>" . htmlspecialchars($rows["ImageURL"]) . "</ImageURL>";
+		$output .=  "<SalesRank>" . htmlspecialchars($rows["SalesRank"]) . "</SalesRank>";
+		$output .=  "<PublicationDate>" . htmlspecialchars($rows["PublicationDate"]) . "</PublicationDate>";
+		$output .=  "<Publisher>" . htmlspecialchars($rows["Publisher"]) . "</Publisher>";
+		$output .=  "<Genre1>" . htmlspecialchars($rows["Genre1"]) . "</Genre1>";
+		$output .=  "<Genre2>" . htmlspecialchars($rows["Genre2"]) . "</Genre2>";
+		$output .=  "<Genre3>" . htmlspecialchars($rows["Genre3"]) . "</Genre3>";
+		$output .=  "<ProductGroup>Book</ProductGroup>";
+	      }
+	      else {
+		# Causes looping behaviour from client :-(
+		dl("gBD:  no DB info either, bailing\n");
+		return;
+	      }
 	    }
 	  }
 	$output .=  "</BookDetails>";