Mercurial > hg > ywww
changeset 8:226f00d9f6f5
another error check
author | Henry Thompson <ht@markup.co.uk> |
---|---|
date | Fri, 17 Feb 2017 15:22:53 +0000 |
parents | 1dfe64e365a0 |
children | 232deb0b066a |
files | us/index.php |
diffstat | 1 files changed, 16 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/us/index.php Fri Feb 17 13:40:20 2017 +0000 +++ b/us/index.php Fri Feb 17 15:22:53 2017 +0000 @@ -140,8 +140,22 @@ { $bookDetails = getAmazonDet($isbn,1,'us'); $bookXML = new SimpleXMLElement($bookDetails); - $title = $bookXML->Items->Item[0]->ItemAttributes->Title; - $author = $bookXML->Items->Item[0]->ItemAttributes->Author; + // HST added this + if (preg_match("<Error>",$bookDetails)) { + $resName=$bookXML->getName(); + $code=$bookXML->Error->Code; + file_put_contents('/var/ywww/debug/phpDebug',"Losing 3: $resName, ". + $code."\n",FILE_APPEND); + if ($code=='RequestThrottled') { + usleep(200000); // Try to reduce throttling until we get a + // principled solution in place + } + $title = ""; + } + else { + $title = $bookXML->Items->Item[0]->ItemAttributes->Title; + $author = $bookXML->Items->Item[0]->ItemAttributes->Author; + } } $linkedBooks = include "../php/read/getLinkedBooks.php";