Mercurial > hg > ywww
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 52:d9dd9705e724 | 53:dd93cb4b77ad |
|---|---|
| 101 } | 101 } |
| 102 } | 102 } |
| 103 else { | 103 else { |
| 104 mysqli_close($link); //do not remove. reset is needed otherwise mysqli_fetch_array doesn't work after first loop | 104 mysqli_close($link); //do not remove. reset is needed otherwise mysqli_fetch_array doesn't work after first loop |
| 105 } | 105 } |
| 106 | 106 dl("gbd: ".strlen($output)." $proceed\n$output\n"); |
| 107 if($proceed == true) | 107 if($proceed == true) |
| 108 { | 108 { |
| 109 include "aws_signed_request.php"; | 109 include "aws_signed_request.php"; |
| 110 include_once "xml/doAmazonRequest.php"; | 110 include_once "xml/doAmazonRequest.php"; |
| 111 | 111 |
| 145 if ($searchindex!='Books') { | 145 if ($searchindex!='Books') { |
| 146 $parameters['SearchIndex']=$searchindex; | 146 $parameters['SearchIndex']=$searchindex; |
| 147 } | 147 } |
| 148 | 148 |
| 149 try { | 149 try { |
| 150 $xml=doAmazonRequest($Aserver[$locale]['ext'],$parameters,6,'d'); | 150 $xml=doAmazonRequest($Aserver[$locale]['ext'],$parameters,2,'d'); |
| 151 //use this xml to pull out the necessary information and save it | 151 //use this xml to pull out the necessary information and save it |
| 152 set_error_handler(function () { | 152 set_error_handler(function () { |
| 153 global $out,$isbn; | 153 global $out,$isbn; |
| 154 dl("Caught one bd: $isbn\n"); | 154 dl("Caught one bd: $isbn\n"); |
| 155 dl(print_r($out, TRUE)."\n"); | 155 dl(print_r($out, TRUE)."\n"); |
| 286 $output .= "<Genre3>" . htmlspecialchars($g3) . "</Genre3>"; | 286 $output .= "<Genre3>" . htmlspecialchars($g3) . "</Genre3>"; |
| 287 $output .= "<ProductGroup>Book</ProductGroup>"; | 287 $output .= "<ProductGroup>Book</ProductGroup>"; |
| 288 } | 288 } |
| 289 catch (Exception $e) { | 289 catch (Exception $e) { |
| 290 dl("gBD: dAR failed:".$e->getMessage()."\n"); | 290 dl("gBD: dAR failed:".$e->getMessage()."\n"); |
| 291 if (isset($rows)) { | |
| 292 dl("gBD: returning stale info from DB: $timeDiff\n"); | |
| 293 /* HST hack, copied from above */ | |
| 294 $output .= "<ISBN>" . $isbn . "</ISBN>"; | |
| 295 $output .= "<Title>" . htmlspecialchars($rows["Title"]) . "</Title>"; | |
| 296 $output .= "<Author>" . htmlspecialchars($rows["Author"]) . "</Author>"; | |
| 297 $output .= "<Binding>" . htmlspecialchars($rows["Binding"]) . "</Binding>"; | |
| 298 $output .= "<Dewey>" . htmlspecialchars($rows["DeweyDecimal"]) . "</Dewey>"; | |
| 299 $output .= "<ImageURL>" . htmlspecialchars($rows["ImageURL"]) . "</ImageURL>"; | |
| 300 $output .= "<SalesRank>" . htmlspecialchars($rows["SalesRank"]) . "</SalesRank>"; | |
| 301 $output .= "<PublicationDate>" . htmlspecialchars($rows["PublicationDate"]) . "</PublicationDate>"; | |
| 302 $output .= "<Publisher>" . htmlspecialchars($rows["Publisher"]) . "</Publisher>"; | |
| 303 $output .= "<Genre1>" . htmlspecialchars($rows["Genre1"]) . "</Genre1>"; | |
| 304 $output .= "<Genre2>" . htmlspecialchars($rows["Genre2"]) . "</Genre2>"; | |
| 305 $output .= "<Genre3>" . htmlspecialchars($rows["Genre3"]) . "</Genre3>"; | |
| 306 $output .= "<ProductGroup>Book</ProductGroup>"; | |
| 307 } | |
| 308 else { | |
| 309 # Causes looping behaviour from client :-( | |
| 310 dl("gBD: no DB info either, bailing\n"); | |
| 311 return; | |
| 312 } | |
| 291 } | 313 } |
| 292 } | 314 } |
| 293 $output .= "</BookDetails>"; | 315 $output .= "</BookDetails>"; |
| 294 | 316 |
| 295 echo $output; | 317 echo $output; |
