comparison xml/getAmazonInfo.php @ 43:dbc006408d2b

ASSUMES we have SetEnv PHP_VALUE "include_path =.:/var/test/private:/var/test/ywww:/usr/share/php" in apache2/.../test.conf use dl(...) for debug logging, defined in dlog.php use doAmazonRequest in amazonBookSearch use ../private/web.php (q.v., not in mercurial) for Aserver and Aassociates Started by updating from 40:c24ae74bf6d5, i.e. just before the bug on the main line
author Charlie Root
date Sat, 05 Jan 2019 18:00:10 -0500
parents 3f400072bf14
children 38d209611508
comparison
equal deleted inserted replaced
42:3f400072bf14 43:dbc006408d2b
1 <?php 1 <?php
2 2 include_once "dlog.php";
3 include_once "doAmazonRequest.inc"; 3 include_once "doAmazonRequest.inc";
4 4
5 function getAmazonDet($isbn,$go,$localeIn) 5 function getAmazonDet($isbn,$go,$localeIn)
6 { 6 {
7 $Adefault=array( 7 $Adefault=array(
60 $page,$operation,$searchparameter, 60 $page,$operation,$searchparameter,
61 $searchparameterdata, 61 $searchparameterdata,
62 $show_array,$show_url,$show_xml) 62 $show_array,$show_url,$show_xml)
63 { 63 {
64 global $output, $Aassociates_id, $Aserver; 64 global $output, $Aassociates_id, $Aserver;
65
66 //if(go != 1) 65 //if(go != 1)
67 //include "aws_signed_request.php"; 66 //include "aws_signed_request.php";
68 //this is the data that is used to form the request for AWS 67 //this is the data that is used to form the request for AWS
69 //this is the part that is search specific 68 //this is the part that is search specific
70 $parameters=array( 69 $parameters=array(
86 $parameters['SearchIndex']=$searchindex; 85 $parameters['SearchIndex']=$searchindex;
87 } 86 }
88 $xml=doAmazonRequest($Aserver[$locale]['ext'],$parameters,3,'i'); // may throw exception 87 $xml=doAmazonRequest($Aserver[$locale]['ext'],$parameters,3,'i'); // may throw exception
89 set_error_handler(function () { 88 set_error_handler(function () {
90 global $output; 89 global $output;
91 file_put_contents('/var/ywww/debug/phpDebug', 90 dl("Caught one?: $searchparameterdata\n");
92 "Caught one?: ".$searchparameterdata, 91 dl(print_r($output, TRUE)."\n");
93 FILE_APPEND);
94 file_put_contents('/var/ywww/debug/phpDebug',
95 print_r($output, TRUE)."\n",
96 FILE_APPEND);
97 } ); 92 } );
98 $review = $xml->Items->Item->CustomerReviews->IFrameURL; 93 $review = $xml->Items->Item->CustomerReviews->IFrameURL;
99 restore_error_handler(); 94 restore_error_handler();
100 //echo $review; 95 //echo $review;
101 if ($review != "") 96 if ($review != "")
191 if($go == 1) { 186 if($go == 1) {
192 $item = $xml->Items->Item[0]; 187 $item = $xml->Items->Item[0];
193 if ($item && $item->ItemAttributes && $item->ItemAttributes->Title) { 188 if ($item && $item->ItemAttributes && $item->ItemAttributes->Title) {
194 $title = $item->ItemAttributes->Title; } 189 $title = $item->ItemAttributes->Title; }
195 else { $title = "[no title]"; }; 190 else { $title = "[no title]"; };
196 file_put_contents('/var/ywww/debug/phpDebug',"win: $title\n", 191 dl("win: $title\n");
197 FILE_APPEND);
198 return $output; 192 return $output;
199 } 193 }
200 else { 194 else {
201 if ($xml->Items->Item) { 195 if ($xml->Items->Item) {
202 $title = $xml->Items->Item[0]->ItemAttributes->Title; 196 $title = $xml->Items->Item[0]->ItemAttributes->Title;
319 313
320 $res = mysqli_query($link, $queryInsert); 314 $res = mysqli_query($link, $queryInsert);
321 if (!$res) { 315 if (!$res) {
322 $err=mysqli_error( $link ); 316 $err=mysqli_error( $link );
323 mysqli_close($link); 317 mysqli_close($link);
324 file_put_contents('/var/ywww/debug/phpDebug', 318 dl("anb failed: $queryInsert\n$err\n");
325 "anb failed: $queryInsert\n$err\n",
326 FILE_APPEND);
327 exit($err); 319 exit($err);
328 } 320 }
329 $queryInsertReviews = "CALL b_insertReviews(\"$searchparameterdata\",\"$review1\",\"$review2\",\"$review3\")"; 321 $queryInsertReviews = "CALL b_insertReviews(\"$searchparameterdata\",\"$review1\",\"$review2\",\"$review3\")";
330 if($review1 != "") { 322 if($review1 != "") {
331 $res = mysqli_query($link, $queryInsertReviews); 323 $res = mysqli_query($link, $queryInsertReviews);
332 if (!$res) { 324 if (!$res) {
333 $err=mysqli_error( $link ); 325 $err=mysqli_error( $link );
334 mysqli_close($link); 326 mysqli_close($link);
335 file_put_contents('/var/ywww/debug/phpDebug', 327 dl("anr failed: $queryInsertReviews\n");
336 "anr failed: $queryInsertReviews\n",
337 FILE_APPEND);
338 exit($err); 328 exit($err);
339 } 329 }
340 } 330 }
341 mysqli_close($link); //do not remove. reset is needed otherwise mysqli_fetch_array doesn't work after first loop 331 mysqli_close($link); //do not remove. reset is needed otherwise mysqli_fetch_array doesn't work after first loop
342 } 332 }
407 } 397 }
408 } 398 }
409 399
410 if(!isset($ret)) 400 if(!isset($ret))
411 { 401 {
412 include "aws_signed_request.php"; 402 getAmazonDet('default',0,'us'); //will get overwritten
413 getAmazonDet('default',0,'us'); //will get overwritten from URI params
414 // by the foreach ($Adefault as ... loop above
415 } 403 }
416 /*Caught oneSimpleXMLElement Object 404 /*Caught oneSimpleXMLElement Object
417 ( 405 (
418 [OperationRequest] => SimpleXMLElement Object 406 [OperationRequest] => SimpleXMLElement Object
419 ( 407 (