Mercurial > hg > ywww
comparison xml/getAmazonInfo.php @ 15:385ddd7c4b55 testing
use test_db.php to get mysqld_test instance
author | Henry S. Thompson <ht@inf.ed.ac.uk> |
---|---|
date | Sun, 19 Feb 2017 16:17:53 +0000 |
parents | c9ebf871114b |
children |
comparison
equal
deleted
inserted
replaced
14:1477b5e6dd16 | 15:385ddd7c4b55 |
---|---|
113 // HST added this | 113 // HST added this |
114 if (preg_match("<Error>",$output)) { | 114 if (preg_match("<Error>",$output)) { |
115 $xml = new SimpleXMLElement($output); | 115 $xml = new SimpleXMLElement($output); |
116 $resName=$xml->getName(); | 116 $resName=$xml->getName(); |
117 $code=$xml->Error->Code; | 117 $code=$xml->Error->Code; |
118 file_put_contents('/var/ywww/debug/phpDebug',"Losing: $resName, $code\n",FILE_APPEND); | 118 file_put_contents('/var/test/ywww/debug/testDebug',"Losing: $resName, $code\n",FILE_APPEND); |
119 if ($code=='RequestThrottled') { | 119 if ($code=='RequestThrottled') { |
120 usleep(200000); // Try to reduce throttling until we get a | 120 usleep(200000); // Try to reduce throttling until we get a |
121 // principled solution in place | 121 // principled solution in place |
122 } | 122 } |
123 else { | 123 else { |
124 file_put_contents('/var/ywww/debug/phpDebug',"parms: $go\n". | 124 file_put_contents('/var/test/ywww/debug/testDebug',"parms: $go\n". |
125 print_r($parameters,TRUE)."\n",FILE_APPEND); | 125 print_r($parameters,TRUE)."\n",FILE_APPEND); |
126 if ($code=="") { | 126 if ($code=="") { |
127 file_put_contents('/var/ywww/debug/phpDebug',"error elt:\n$output\n",FILE_APPEND); | 127 file_put_contents('/var/test/ywww/debug/testDebug',"error elt:\n$output\n",FILE_APPEND); |
128 } | 128 } |
129 } | 129 } |
130 } | 130 } |
131 else { | 131 else { |
132 $xml = new SimpleXMLElement($output); | 132 $xml = new SimpleXMLElement($output); |
133 set_error_handler(function () { | 133 set_error_handler(function () { |
134 global $output; | 134 global $output; |
135 file_put_contents('/var/ywww/debug/phpDebug', | 135 file_put_contents('/var/test/ywww/debug/testDebug', |
136 "Caught one?: ".$searchparameterdata, | 136 "Caught one?: ".$searchparameterdata, |
137 FILE_APPEND); | 137 FILE_APPEND); |
138 file_put_contents('/var/ywww/debug/phpDebug', | 138 file_put_contents('/var/test/ywww/debug/testDebug', |
139 print_r($output, TRUE)."\n", | 139 print_r($output, TRUE)."\n", |
140 FILE_APPEND); | 140 FILE_APPEND); |
141 } ); | 141 } ); |
142 $review = $xml->Items->Item->CustomerReviews->IFrameURL; | 142 $review = $xml->Items->Item->CustomerReviews->IFrameURL; |
143 // The above is failing repeatedly -- | 143 // The above is failing repeatedly -- |
144 //PHP Notice: Trying to get property of non-object in | 144 //PHP Notice: Trying to get property of non-object in |
145 // /var/ywww/xml/getAmazonInfo.php on line [109] | 145 // /var/test/ywww/xml/getAmazonInfo.php on line [109] |
146 // See the dumped structure at the end of this file for the | 146 // See the dumped structure at the end of this file for the |
147 // cause | 147 // cause |
148 restore_error_handler(); | 148 restore_error_handler(); |
149 //echo $review; | 149 //echo $review; |
150 $review1 = ""; | 150 $review1 = ""; |
260 //echo $errorCode; | 260 //echo $errorCode; |
261 | 261 |
262 if($errorCode != "AccountLimitExceeded") | 262 if($errorCode != "AccountLimitExceeded") |
263 { | 263 { |
264 if($go == 1) { | 264 if($go == 1) { |
265 file_put_contents('/var/ywww/debug/phpDebug',"win: ". | 265 file_put_contents('/var/test/ywww/debug/testDebug',"win: ". |
266 $xml->Items->Item->ItemAttributes->Title."\n", | 266 $xml->Items->Item->ItemAttributes->Title."\n", |
267 FILE_APPEND); | 267 FILE_APPEND); |
268 return $output; | 268 return $output; |
269 } | 269 } |
270 else | 270 else |
306 | 306 |
307 foreach ($genArr as $key => $value) { | 307 foreach ($genArr as $key => $value) { |
308 //echo "$key => $value"; | 308 //echo "$key => $value"; |
309 $queryG = "CALL b_addBrowseNode($key,\"$value\")"; //add the name value pair for genre to new table | 309 $queryG = "CALL b_addBrowseNode($key,\"$value\")"; //add the name value pair for genre to new table |
310 //echo $queryG; | 310 //echo $queryG; |
311 include "../../private/db.php"; | 311 include "../../../private/db_test.php"; |
312 $resG = mysqli_query($link, $queryG); | 312 $resG = mysqli_query($link, $queryG); |
313 mysqli_close($link); | 313 mysqli_close($link); |
314 | 314 |
315 switch ($loop) { | 315 switch ($loop) { |
316 case 1: | 316 case 1: |
329 | 329 |
330 if($salesRank == "") | 330 if($salesRank == "") |
331 $salesRank = "null"; | 331 $salesRank = "null"; |
332 | 332 |
333 $title = strtr($title, '"', "'"); | 333 $title = strtr($title, '"', "'"); |
334 include "../../private/db.php"; | 334 include "../../../private/db_test.php"; |
335 $review1 = mysqli_real_escape_string($link,$review1); | 335 $review1 = mysqli_real_escape_string($link,$review1); |
336 $review2 = mysqli_real_escape_string($link,$review2); | 336 $review2 = mysqli_real_escape_string($link,$review2); |
337 $review3 = mysqli_real_escape_string($link,$review3); | 337 $review3 = mysqli_real_escape_string($link,$review3); |
338 | 338 |
339 if($title != "") | 339 if($title != "") |
353 } | 353 } |
354 } | 354 } |
355 else | 355 else |
356 { | 356 { |
357 //look up info from db | 357 //look up info from db |
358 include "../../private/db.php"; | 358 include "../../../private/db_test.php"; |
359 $query = "CALL b_getBookInfo('$searchparameterdata', $loc)"; | 359 $query = "CALL b_getBookInfo('$searchparameterdata', $loc)"; |
360 //echo $query; | 360 //echo $query; |
361 $res = mysqli_query($link, $query) or exit( mysqli_error( $link )); | 361 $res = mysqli_query($link, $query) or exit( mysqli_error( $link )); |
362 | 362 |
363 $output = ""; | 363 $output = ""; |