annotate xml/getAmazonInfo.php @ 35:86f79bc1d142

refactor to split out shareable fn to actually do an Amazon API request
author Charlie Root
date Fri, 04 Jan 2019 12:54:12 -0500
parents c9d9b76ecbf9
children 2c0c95bd97a6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4
a6b55ae70617 original
robert
parents:
diff changeset
1 <?php
a6b55ae70617 original
robert
parents:
diff changeset
2
35
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
3 include_once "doAmazonRequest.inc";
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
4
4
a6b55ae70617 original
robert
parents:
diff changeset
5 function getAmazonDet($isbn,$go,$localeIn)
a6b55ae70617 original
robert
parents:
diff changeset
6 {
32
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
7 $Adefault=array(
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
8 'language' =>'en', //what language to render the page in
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
9 'locale' =>$localeIn, //which server's products? available: ca,de,fr,jp,uk,us
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
10 //'mode' =>'books', //what product category?
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
11 'page' =>1, //first page to show (we are counting from 1 not 0)
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
12 //'search' =>'Machiavelli', //what to search for?
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
13 'operation' =>'ItemLookup', //what to do? //ItemSearch
33
c9d9b76ecbf9 minor tidying
Charlie Root
parents: 32
diff changeset
14 'searchindex' =>'Books', //what product category for search?
32
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
15 'searchparameter' =>'ItemId', //what kind of search?
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
16 'searchparameterdata'=>$isbn, //what to search for?
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
17 //here some debugging flags you can put at the end of the URL to call this script with, like: '?show_array=true'
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
18 'show_array' =>false, //debug: show complete incoming array? You can use this to see what other information Amazon is sending
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
19 'show_url' =>false, //debug: show XML request url to be send to Amazon?
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
20 'show_xml' =>false, //debug: show incoming XML code from Amazon?
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
21 );
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
22 //change the debug options to true if you want to activate them or call the script with '?show_array=true' to see what actual information you're getting from Amazon and how little my standard script is actually showing of it
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
23 //for all parameters see if the user has overruled it or use the default
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
24 foreach ($Adefault as $i=>$d) {
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
25 $$i=isset($_GET[$i])?$_GET[$i]:$d;
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
26 }
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
27 switch($locale){
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
28 case "us":
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
29 $loc = 0;
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
30 break;
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
31 case "uk":
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
32 $loc = 1;
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
33 break;
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
34 case "ca":
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
35 $loc = 2;
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
36 break;
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
37 case "de":
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
38 $loc = 3;
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
39 break;
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
40 case "fr":
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
41 $loc = 4;
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
42 break;
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
43 };
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
44
35
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
45 try {
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
46 return getAmazonDetRemote($go,$language,$locale,$loc,
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
47 $page,$operation,$searchparameter,
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
48 $searchparameterdata,
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
49 $show_array,$show_url,$show_xml);
32
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
50 }
35
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
51 catch (Exception $e) {
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
52 return getAmazonDetLocal($go,$language,$loc,
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
53 $page,$operation,$searchparameter,
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
54 $searchparameterdata,
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
55 $show_array,$show_url,$show_xml);
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
56 }
32
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
57 }
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
58
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
59 function getAmazonDetRemote($go,$language,$locale,$loc,
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
60 $page,$operation,$searchparameter,
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
61 $searchparameterdata,
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
62 $show_array,$show_url,$show_xml)
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
63 {
4
a6b55ae70617 original
robert
parents:
diff changeset
64 global $output;
a6b55ae70617 original
robert
parents:
diff changeset
65
32
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
66 $Aassociates_id=array(
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
67 'uk' => 'bookwhack-21',
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
68 'us' => 'your02b-20',
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
69 'ca' => 'book009-20',
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
70 'de' => 'book04c-21',
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
71 'fr' => 'book07f-21',
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
72 );
4
a6b55ae70617 original
robert
parents:
diff changeset
73
32
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
74 $Aserver=array(
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
75 'ca' => array(
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
76 'ext' => 'ca' , //Canadian normal server
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
77 'nor' => 'http://www.amazon.ca' , //Canadian normal server
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
78 'xml' => 'http://xml.amazon.com' , //Canadian xml server
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
79 ),
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
80 'de' => array(
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
81 'ext' => 'de' , //German normal server
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
82 'nor' => 'http://www.amazon.de' , //German normal server
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
83 'xml' => 'http://xml-eu.amazon.com', //German xml server
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
84 ),
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
85 'fr' => array(
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
86 'ext' => 'fr' , //French normal server
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
87 'nor' => 'http://www.amazon.fr' , //French normal server
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
88 'xml' => 'http://xml-eu.amazon.com', //French xml server
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
89 ),
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
90 'jp' => array(
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
91 'ext' => 'jp' , //Japanese normal server, not co.jp!
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
92 'nor' => 'http://www.amazon.co.jp' , //Japanese normal server
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
93 'xml' => 'http://xml.amazon.com' , //Japanese xml server
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
94 ),
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
95 'uk' => array(
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
96 'ext' => 'co.uk' , //UK normal server
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
97 'nor' => 'http://www.amazon.co.uk' , //UK normal server
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
98 'xml' => 'http://xml-eu.amazon.com', //UK xml server
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
99 ),
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
100 'us' => array(
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
101 'ext' => 'com' , //USA normal server
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
102 'nor' => 'http://www.amazon.com' , //USA normal server
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
103 'xml' => 'http://xml.amazon.com' , //USA xml server
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
104 ),
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
105 );
4
a6b55ae70617 original
robert
parents:
diff changeset
106
32
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
107 //if(go != 1)
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
108 //include "aws_signed_request.php";
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
109 //this is the data that is used to form the request for AWS
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
110 //this is the part that is search specific
4
a6b55ae70617 original
robert
parents:
diff changeset
111 $parameters=array(
32
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
112 'Operation' =>$operation ,
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
113 //'Keywords' =>urlencode($search) ,
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
114 "$searchparameter"=>$searchparameterdata ,
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
115 'ItemPage' =>$page , //which page?
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
116 'AssociateTag' =>$Aassociates_id[$locale],
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
117 'ResponseGroup' =>'ItemAttributes,Reviews,EditorialReview,OfferSummary,Offers,Images,AlternateVersions,SalesRank,BrowseNodes' , //Small, Medium, Large or SellerListing,'BrowseNodes',// ,
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
118 'ReviewSort' =>'-HelpfulVotes'
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
119 );
4
a6b55ae70617 original
robert
parents:
diff changeset
120
33
c9d9b76ecbf9 minor tidying
Charlie Root
parents: 32
diff changeset
121 if (isset($searchindex) && $searchindex!='Books') {
c9d9b76ecbf9 minor tidying
Charlie Root
parents: 32
diff changeset
122 // HST did this
c9d9b76ecbf9 minor tidying
Charlie Root
parents: 32
diff changeset
123 // Used to be in $parameters init above, but
c9d9b76ecbf9 minor tidying
Charlie Root
parents: 32
diff changeset
124 // that caused an error:
c9d9b76ecbf9 minor tidying
Charlie Root
parents: 32
diff changeset
125 // If idType equals ASIN, SearchIndex cannot be present
c9d9b76ecbf9 minor tidying
Charlie Root
parents: 32
diff changeset
126 //'SearchIndex' =>$searchindex , //Books for example.
c9d9b76ecbf9 minor tidying
Charlie Root
parents: 32
diff changeset
127 $parameters['SearchIndex']=$searchindex;
c9d9b76ecbf9 minor tidying
Charlie Root
parents: 32
diff changeset
128 }
35
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
129 $xml=doAmazonRequest($Aserver[$locale]['ext'],$parameters,3); // may throw exception
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
130 set_error_handler(function () {
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
131 global $output;
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
132 file_put_contents('/var/ywww/debug/phpDebug',
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
133 "Caught one?: ".$searchparameterdata,
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
134 FILE_APPEND);
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
135 file_put_contents('/var/ywww/debug/phpDebug',
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
136 print_r($output, TRUE)."\n",
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
137 FILE_APPEND);
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
138 } );
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
139 $review = $xml->Items->Item->CustomerReviews->IFrameURL;
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
140 restore_error_handler();
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
141 //echo $review;
32
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
142 if ($review != "")
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
143 {
35
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
144 $review1 = "";
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
145 $review2 = "";
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
146 $review3 = "";
32
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
147 $text = @file_get_contents($review . "&truncate=300");
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
148 $removeTop1 = preg_replace('~<div class="crIFrameHeaderLeftColumn">(.*?)<div class="crIFrameHeaderHistogram">~si', '', $text);
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
149 $removeTop2 = preg_replace('~<div class="crIFrameHeaderHistogram">(.*?)<div class="crIframeReviewList">~si', '', $text);
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
150 if (preg_match('~<body[^>]*>(.*?)</body>~si', $removeTop2, $body)){ $getBody = trim($body[1]); } else { $getBody = $removeTop2;}
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
151 $removeDiv = preg_replace('~<div[^>]*>(.*?)</div>~si', '', $getBody);
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
152 $removeCloseDivs = preg_replace('/<\/div>/','', $removeDiv);
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
153 $setBoundary = str_replace('<!-- BOUNDARY -->','BOTTOM-TOP', $removeCloseDivs);
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
154 //replace <!-- BOUNDARY --> with BOTTOM-TOP
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
155 $remove1 = '~<table cellpadding="0"(.*?)%">~s';
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
156 $setBoundary = preg_replace($remove1,'', $setBoundary);
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
157 $remove2 = '~</td><td bg(.*?)</table>~s';
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
158 $setBoundary = preg_replace($remove2,'', $setBoundary);
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
159 $remove3 = '~<a name=(.*?)</a>~s';
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
160 $setBoundary = preg_replace($remove3,'', $setBoundary);
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
161 $setBoundary2 = str_replace('<br />','', $setBoundary);
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
162 //remove all extra crap;
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
163 $setBoundary3 = str_replace('</td>','BOTTOM', $setBoundary2);
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
164 //replace </td> with BOTTOM
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
165
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
166 if (preg_match_all('~TOP(.*?)BOTTOM~s', $setBoundary3, $reviews))
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
167 {
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
168 $reviewContents = $reviews[1];
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
169 //print_r($reviewContents);
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
170 $review1 = trim($reviewContents[0]);
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
171 $review1 = str_replace("\n", "", $review1);
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
172 $review1 = str_replace("\r", "", $review1);
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
173 if (isset($reviewContents[1])) {
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
174 $review2 = trim($reviewContents[1]);
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
175 $review2 = str_replace("\n", "", $review2);
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
176 $review2 = str_replace("\r", "", $review2);
7
1dfe64e365a0 a bit more debugging/bomb-proofing
Robert Boland <robert@markup.co.uk>
parents: 5
diff changeset
177 }
9
232deb0b066a tidy up debugging, only show parms on non-throttled error
Henry S. Thompson <ht@markup.co.uk>
parents: 7
diff changeset
178 else {
32
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
179 $review2 = "";
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
180 }
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
181 if (isset($reviewContents[2])) {
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
182 $review3 = trim($reviewContents[2]);
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
183 $review3 = str_replace("\n", "", $review3);
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
184 $review3 = str_replace("\r", "", $review3);
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
185 }
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
186 else {
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
187 $review3 = "";
9
232deb0b066a tidy up debugging, only show parms on non-throttled error
Henry S. Thompson <ht@markup.co.uk>
parents: 7
diff changeset
188 }
5
55445b456ad0 short-circuit error response handling, add debugging
robert
parents: 4
diff changeset
189 }
32
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
190 else
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
191 {
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
192 $review1 = "";
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
193 $review2 = "";
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
194 $review3 = "";
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
195 //echo "EPIC FAIL";
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
196 }
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
197
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
198 unset($xml->Items->Item->CustomerReviews);
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
199 $xdoc = new DomDocument;
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
200 $xdoc->loadXML($xml->asXML());
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
201
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
202 $cReviews = $xdoc ->createElement('CustomerReviews');
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
203 $cReviewHolder = $xdoc ->createElement('Review');
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
204 $cReview = $xdoc ->createElement('Content');
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
205 $cReviewHolder2 = $xdoc ->createElement('Review');
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
206 $cReview2 = $xdoc ->createElement('Content');
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
207 $cReviewHolder3 = $xdoc ->createElement('Review');
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
208 $cReview3 = $xdoc ->createElement('Content');
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
209
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
210 $txtNode = $xdoc ->createTextNode ($review1);
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
211 $cReview -> appendChild($txtNode);
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
212
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
213 $txtNode2 = $xdoc ->createTextNode ($review2);
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
214 $cReview2 -> appendChild($txtNode2);
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
215
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
216 $txtNode3 = $xdoc ->createTextNode ($review3);
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
217 $cReview3 -> appendChild($txtNode3);
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
218
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
219 $cReviewHolder -> appendChild($cReview);
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
220 $cReviewHolder2 -> appendChild($cReview2);
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
221 $cReviewHolder3 -> appendChild($cReview3);
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
222
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
223 $cReviews -> appendChild($cReviewHolder);
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
224 $cReviews -> appendChild($cReviewHolder2);
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
225 $cReviews -> appendChild($cReviewHolder3);
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
226
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
227 $xdoc->documentElement->childNodes->item(1)->childNodes->item(1)->appendChild($cReviews);
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
228 $newXML = simplexml_import_dom($xdoc);
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
229 $output = $newXML->asXml();
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
230 }
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
231
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
232 if($go == 1) {
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
233 $item = $xml->Items->Item[0];
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
234 if ($item && $item->ItemAttributes && $item->ItemAttributes->Title) {
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
235 $title = $item->ItemAttributes->Title; }
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
236 else { $title = "[no title]"; };
35
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
237 file_put_contents('/var/ywww/debug/phpDebug',"win: $title\n",
32
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
238 FILE_APPEND);
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
239 return $output;
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
240 }
35
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
241 else {
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
242 if ($xml->Items->Item) {
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
243 $title = $xml->Items->Item[0]->ItemAttributes->Title;
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
244 $author = $xml->Items->Item[0]->ItemAttributes->Author;
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
245 $binding = $xml->Items->Item[0]->ItemAttributes->Binding;
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
246 $dewey = $xml->Items->Item[0]->ItemAttributes->DeweyDecimalNumber;
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
247 if($dewey == "")
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
248 $dewey = "null";
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
249 $imageURL = $xml->Items->Item[0]->MediumImage->URL;
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
250 $salesRank = $xml->Items->Item[0]->SalesRank;
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
251 $pubDate = $xml->Items->Item[0]->ItemAttributes->PublicationDate;
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
252 if (strlen($pubDate)==4) { $pubDate=$pubDate."-01-01";}
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
253 if (strlen($pubDate)==7) { $pubDate=$pubDate."-01";}
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
254 if (strlen($pubDate)==0) {
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
255 $pubDate="null";
32
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
256 }
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
257 else {
35
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
258 $pubDate="\"$pubDate\"";
32
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
259 }
35
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
260 $publisher = $xml->Items->Item[0]->ItemAttributes->Publisher;
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
261 }
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
262 else {
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
263 $title = $salesRank = "";
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
264 $dewey = "null";
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
265 }
32
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
266
35
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
267 $genreID = "";
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
268 $genre = "";
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
269 $genArr = array();
32
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
270
35
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
271 if ($xml->Items->Item[0] && $xml->Items->Item[0]->BrowseNodes) {
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
272 for($i=0;$i<sizeof($xml->Items->Item->BrowseNodes->BrowseNode);$i++){
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
273 //sexy recursive function
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
274 findGenre($xml->Items->Item->BrowseNodes->BrowseNode[$i], $genreID, $genre);
32
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
275
35
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
276 if($genre != "")
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
277 $genArr[strval($genreID)] = strval($genre);
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
278 //$genArr[$i] = array(strval($genreID) => strval($genre));
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
279
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
280 //echo $genre;
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
281 //echo $genreID;
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
282
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
283 $genre = "";
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
284 $genreID = "";
32
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
285 }
35
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
286 }
32
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
287
35
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
288 $g1 = "null";
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
289 $g2 = "null";
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
290 $g3 = "null";
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
291 $loop = 1;
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
292
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
293 foreach ($genArr as $key => $value) {
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
294 //echo "$key => $value";
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
295 if ($key>2047) {
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
296 //HST added
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
297 break;
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
298 }
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
299 $queryG = "CALL b_addBrowseNode($key,\"$value\")"; //add the name value pair for genre to new table
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
300 //echo $queryG;
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
301 include "../../private/db.php";
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
302 $resG = mysqli_query($link, $queryG);
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
303 mysqli_close($link);
32
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
304
35
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
305 switch ($loop) {
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
306 case 1:
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
307 $g1 = $key;
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
308 break;
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
309 case 2:
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
310 $g2 = $key;
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
311 break;
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
312 case 3:
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
313 $g3 = $key;
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
314 break;
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
315 }
32
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
316
35
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
317 $loop++;
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
318 }
32
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
319
35
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
320 if($salesRank == "")
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
321 $salesRank = "null";
32
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
322
35
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
323 if($title != "")
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
324 {
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
325 include "../../private/db.php";
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
326 if ($publisher->count()==0) {
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
327 $publisher="null";
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
328 }
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
329 else {
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
330 $publisher=mysqli_real_escape_string($link,$publisher);
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
331 if (strlen($publisher)>30) {
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
332 $publisher=rtrim(substr($publisher,0,30),"\\");
32
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
333 }
35
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
334 $publisher="\"".$publisher."\"";
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
335 }
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
336 if ($author->count()==0) {
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
337 $author="unknown";
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
338 }
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
339 else {
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
340 $author=mysqli_real_escape_string($link,$author);
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
341 if (strlen($author)>30) {
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
342 $author=rtrim(substr($author,0,30),"\\");
32
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
343 }
35
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
344 }
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
345 $author="\"".$author."\"";
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
346 $title=mysqli_real_escape_string($link,$title);
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
347 if (strlen($title)>100) {
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
348 $title=rtrim(substr($title,0,100),"\\");
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
349 }
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
350 $title="\"".$title."\"";
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
351 $review1 = mysqli_real_escape_string($link,$review1);
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
352 if (strlen($review1)>500) { $review1=rtrim(substr($review1,0,500),"\\");}
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
353 $review2 = mysqli_real_escape_string($link,$review2);
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
354 if (strlen($review2)>500) { $review2=rtrim(substr($review2,0,500),"\\");}
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
355 $review3 = mysqli_real_escape_string($link,$review3);
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
356 if (strlen($review3)>500) { $review3=rtrim(substr($review3,0,500),"\\");}
4
a6b55ae70617 original
robert
parents:
diff changeset
357
35
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
358 $queryInsert = "CALL b_addNewBook(\"$searchparameterdata\",$title, $author,\"$binding\",\"$imageURL\", $dewey, $salesRank,$pubDate,$publisher,$g1,$g2,$g3,$loc)";
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
359 //echo $queryInsert;
25
828895488948 more db column protection
Robert Boland <robert@markup.co.uk>
parents: 23
diff changeset
360
35
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
361 $res = mysqli_query($link, $queryInsert);
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
362 if (!$res) {
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
363 $err=mysqli_error( $link );
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
364 mysqli_close($link);
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
365 file_put_contents('/var/ywww/debug/phpDebug',
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
366 "anb failed: $queryInsert\n$err\n",
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
367 FILE_APPEND);
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
368 exit($err);
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
369 }
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
370 $queryInsertReviews = "CALL b_insertReviews(\"$searchparameterdata\",\"$review1\",\"$review2\",\"$review3\")";
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
371 if($review1 != "") {
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
372 $res = mysqli_query($link, $queryInsertReviews);
32
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
373 if (!$res) {
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
374 $err=mysqli_error( $link );
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
375 mysqli_close($link);
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
376 file_put_contents('/var/ywww/debug/phpDebug',
35
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
377 "anr failed: $queryInsertReviews\n",
32
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
378 FILE_APPEND);
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
379 exit($err);
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
380 }
4
a6b55ae70617 original
robert
parents:
diff changeset
381 }
35
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
382 mysqli_close($link); //do not remove. reset is needed otherwise mysqli_fetch_array doesn't work after first loop
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
383 }
32
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
384
35
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
385 echo $output;
86f79bc1d142 refactor to split out shareable fn to actually do an Amazon API request
Charlie Root
parents: 33
diff changeset
386 }
32
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
387 }
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
388
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
389 function getAmazonDetLocal($go,$language,$loc,
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
390 $page,$operation,$searchparameter,
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
391 $searchparameterdata,
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
392 $show_array,$show_url,$show_xml)
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
393 {
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
394 global $output;
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
395 //look up info from db
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
396 include "../../private/db.php";
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
397 $query = "CALL b_getBookInfo('$searchparameterdata', $loc)";
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
398 //echo $query;
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
399 $res = mysqli_query($link, $query) or exit( mysqli_error( $link ));
4
a6b55ae70617 original
robert
parents:
diff changeset
400
32
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
401 $output = "";
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
402 $output .= "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
403 $output .= "<Details>";
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
404 if ( mysqli_num_rows( $res ) > 0 )
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
405 {
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
406 $rows=mysqli_fetch_array($res, MYSQLI_ASSOC);
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
407 mysqli_close($link); //do not remove. reset is needed otherwise mysqli_fetch_array doesn't work after first loop
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
408 $output .= "<ASIN>" . $searchparameterdata . "</ASIN>";
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
409 $output .= "<Title>" . htmlspecialchars($rows["Title"]) . "</Title>";
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
410 $output .= "<Author>" . htmlspecialchars($rows["Author"]) . "</Author>";
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
411 $output .= "<Binding>" . htmlspecialchars($rows["Binding"]) . "</Binding>";
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
412 $output .= "<Dewey>" . htmlspecialchars($rows["DeweyDecimal"]) . "</Dewey>";
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
413 $output .= "<ImageURL>" . htmlspecialchars($rows["ImageURL"]) . "</ImageURL>";
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
414 $output .= "<SalesRank>" . htmlspecialchars($rows["SalesRank"]) . "</SalesRank>";
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
415 $output .= "<PublicationDate>" . htmlspecialchars($rows["PublicationDate"]) . "</PublicationDate>";
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
416 $output .= "<Publisher>" . htmlspecialchars($rows["Publisher"]) . "</Publisher>";
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
417 $output .= "<Genre1>" . htmlspecialchars($rows["Genre1"]) . "</Genre1>";
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
418 $output .= "<Genre2>" . htmlspecialchars($rows["Genre2"]) . "</Genre2>";
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
419 $output .= "<Genre3>" . htmlspecialchars($rows["Genre3"]) . "</Genre3>";
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
420 $output .= "<ProductGroup>Book</ProductGroup>";
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
421 $output .= "<Error>AccountLimitExceeded</Error>";
4
a6b55ae70617 original
robert
parents:
diff changeset
422
32
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
423 }
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
424 else {
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
425 mysqli_close($link); //do not remove. reset is needed otherwise mysqli_fetch_array doesn't work after first loop
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
426 }
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
427 $output .= "</Details>";
8130865e9e82 refactor to try to improve error handling
Charlie Root
parents: 31
diff changeset
428 echo $output;
4
a6b55ae70617 original
robert
parents:
diff changeset
429 }
a6b55ae70617 original
robert
parents:
diff changeset
430
a6b55ae70617 original
robert
parents:
diff changeset
431 function findGenre($browseNode, &$ID, &$gen)
a6b55ae70617 original
robert
parents:
diff changeset
432 {
a6b55ae70617 original
robert
parents:
diff changeset
433 if($browseNode->Name == "Subjects")
a6b55ae70617 original
robert
parents:
diff changeset
434 {
a6b55ae70617 original
robert
parents:
diff changeset
435 return true;
a6b55ae70617 original
robert
parents:
diff changeset
436 }
a6b55ae70617 original
robert
parents:
diff changeset
437 else
a6b55ae70617 original
robert
parents:
diff changeset
438 {
a6b55ae70617 original
robert
parents:
diff changeset
439 if($browseNode->Ancestors->BrowseNode)
a6b55ae70617 original
robert
parents:
diff changeset
440 {
a6b55ae70617 original
robert
parents:
diff changeset
441 if(findGenre($browseNode->Ancestors->BrowseNode, $ID, $gen) == true)
a6b55ae70617 original
robert
parents:
diff changeset
442 {
a6b55ae70617 original
robert
parents:
diff changeset
443 $gen = $browseNode->Name;
a6b55ae70617 original
robert
parents:
diff changeset
444 $ID = $browseNode->BrowseNodeId;
a6b55ae70617 original
robert
parents:
diff changeset
445 }
a6b55ae70617 original
robert
parents:
diff changeset
446 }
a6b55ae70617 original
robert
parents:
diff changeset
447 return false;
a6b55ae70617 original
robert
parents:
diff changeset
448 }
a6b55ae70617 original
robert
parents:
diff changeset
449 }
a6b55ae70617 original
robert
parents:
diff changeset
450
a6b55ae70617 original
robert
parents:
diff changeset
451 if(!isset($ret))
a6b55ae70617 original
robert
parents:
diff changeset
452 {
a6b55ae70617 original
robert
parents:
diff changeset
453 include "aws_signed_request.php";
a6b55ae70617 original
robert
parents:
diff changeset
454 getAmazonDet('default',0,'us'); //will get overwritten
a6b55ae70617 original
robert
parents:
diff changeset
455 }
a6b55ae70617 original
robert
parents:
diff changeset
456 /*Caught oneSimpleXMLElement Object
a6b55ae70617 original
robert
parents:
diff changeset
457 (
a6b55ae70617 original
robert
parents:
diff changeset
458 [OperationRequest] => SimpleXMLElement Object
a6b55ae70617 original
robert
parents:
diff changeset
459 (
a6b55ae70617 original
robert
parents:
diff changeset
460 [RequestId] => d2eaacba-2411-44e7-b268-f23a20167330
a6b55ae70617 original
robert
parents:
diff changeset
461 [Arguments] => SimpleXMLElement Object
a6b55ae70617 original
robert
parents:
diff changeset
462 (
a6b55ae70617 original
robert
parents:
diff changeset
463 [Argument] => Array
a6b55ae70617 original
robert
parents:
diff changeset
464 (
a6b55ae70617 original
robert
parents:
diff changeset
465 [0] => SimpleXMLElement Object
a6b55ae70617 original
robert
parents:
diff changeset
466 (
a6b55ae70617 original
robert
parents:
diff changeset
467 [@attributes] => Array
a6b55ae70617 original
robert
parents:
diff changeset
468 (
a6b55ae70617 original
robert
parents:
diff changeset
469 [Name] => AWSAccessKeyId
17
ae1459564f66 Replace old associate keys with new IAMs user keys
Robert Boland <robert@markup.co.uk>
parents: 11
diff changeset
470 [Value] => AKIAIHTNWC7L6LOUY4LQ
4
a6b55ae70617 original
robert
parents:
diff changeset
471 )
a6b55ae70617 original
robert
parents:
diff changeset
472
a6b55ae70617 original
robert
parents:
diff changeset
473 )
a6b55ae70617 original
robert
parents:
diff changeset
474
a6b55ae70617 original
robert
parents:
diff changeset
475 [1] => SimpleXMLElement Object
a6b55ae70617 original
robert
parents:
diff changeset
476 (
a6b55ae70617 original
robert
parents:
diff changeset
477 [@attributes] => Array
a6b55ae70617 original
robert
parents:
diff changeset
478 (
a6b55ae70617 original
robert
parents:
diff changeset
479 [Name] => AssociateTag
a6b55ae70617 original
robert
parents:
diff changeset
480 [Value] => bookwhack-21
a6b55ae70617 original
robert
parents:
diff changeset
481 )
a6b55ae70617 original
robert
parents:
diff changeset
482
a6b55ae70617 original
robert
parents:
diff changeset
483 )
a6b55ae70617 original
robert
parents:
diff changeset
484
a6b55ae70617 original
robert
parents:
diff changeset
485 [2] => SimpleXMLElement Object
a6b55ae70617 original
robert
parents:
diff changeset
486 (
a6b55ae70617 original
robert
parents:
diff changeset
487 [@attributes] => Array
a6b55ae70617 original
robert
parents:
diff changeset
488 (
a6b55ae70617 original
robert
parents:
diff changeset
489 [Name] => ItemId
a6b55ae70617 original
robert
parents:
diff changeset
490 [Value] => B004Q3Q3Y4
a6b55ae70617 original
robert
parents:
diff changeset
491 )
a6b55ae70617 original
robert
parents:
diff changeset
492
a6b55ae70617 original
robert
parents:
diff changeset
493 )
a6b55ae70617 original
robert
parents:
diff changeset
494
a6b55ae70617 original
robert
parents:
diff changeset
495 [3] => SimpleXMLElement Object
a6b55ae70617 original
robert
parents:
diff changeset
496 (
a6b55ae70617 original
robert
parents:
diff changeset
497 [@attributes] => Array
a6b55ae70617 original
robert
parents:
diff changeset
498 (
a6b55ae70617 original
robert
parents:
diff changeset
499 [Name] => ItemPage
a6b55ae70617 original
robert
parents:
diff changeset
500 [Value] => 1
a6b55ae70617 original
robert
parents:
diff changeset
501 )
a6b55ae70617 original
robert
parents:
diff changeset
502
a6b55ae70617 original
robert
parents:
diff changeset
503 )
a6b55ae70617 original
robert
parents:
diff changeset
504
a6b55ae70617 original
robert
parents:
diff changeset
505 [4] => SimpleXMLElement Object
a6b55ae70617 original
robert
parents:
diff changeset
506 (
a6b55ae70617 original
robert
parents:
diff changeset
507 [@attributes] => Array
a6b55ae70617 original
robert
parents:
diff changeset
508 (
a6b55ae70617 original
robert
parents:
diff changeset
509 [Name] => Operation
a6b55ae70617 original
robert
parents:
diff changeset
510 [Value] => ItemLookup
a6b55ae70617 original
robert
parents:
diff changeset
511 )
a6b55ae70617 original
robert
parents:
diff changeset
512
a6b55ae70617 original
robert
parents:
diff changeset
513 )
a6b55ae70617 original
robert
parents:
diff changeset
514
a6b55ae70617 original
robert
parents:
diff changeset
515 [5] => SimpleXMLElement Object
a6b55ae70617 original
robert
parents:
diff changeset
516 (
a6b55ae70617 original
robert
parents:
diff changeset
517 [@attributes] => Array
a6b55ae70617 original
robert
parents:
diff changeset
518 (
a6b55ae70617 original
robert
parents:
diff changeset
519 [Name] => ResponseGroup
a6b55ae70617 original
robert
parents:
diff changeset
520 [Value] => ItemAttributes,Reviews,EditorialReview,OfferSummary,Offers,Images,AlternateVersions,SalesRank,BrowseNodes
a6b55ae70617 original
robert
parents:
diff changeset
521 )
a6b55ae70617 original
robert
parents:
diff changeset
522
a6b55ae70617 original
robert
parents:
diff changeset
523 )
a6b55ae70617 original
robert
parents:
diff changeset
524
a6b55ae70617 original
robert
parents:
diff changeset
525 [6] => SimpleXMLElement Object
a6b55ae70617 original
robert
parents:
diff changeset
526 (
a6b55ae70617 original
robert
parents:
diff changeset
527 [@attributes] => Array
a6b55ae70617 original
robert
parents:
diff changeset
528 (
a6b55ae70617 original
robert
parents:
diff changeset
529 [Name] => ReviewSort
a6b55ae70617 original
robert
parents:
diff changeset
530 [Value] => -HelpfulVotes
a6b55ae70617 original
robert
parents:
diff changeset
531 )
a6b55ae70617 original
robert
parents:
diff changeset
532
a6b55ae70617 original
robert
parents:
diff changeset
533 )
a6b55ae70617 original
robert
parents:
diff changeset
534
a6b55ae70617 original
robert
parents:
diff changeset
535 [7] => SimpleXMLElement Object
a6b55ae70617 original
robert
parents:
diff changeset
536 (
a6b55ae70617 original
robert
parents:
diff changeset
537 [@attributes] => Array
a6b55ae70617 original
robert
parents:
diff changeset
538 (
a6b55ae70617 original
robert
parents:
diff changeset
539 [Name] => Service
a6b55ae70617 original
robert
parents:
diff changeset
540 [Value] => AWSECommerceService
a6b55ae70617 original
robert
parents:
diff changeset
541 )
a6b55ae70617 original
robert
parents:
diff changeset
542
a6b55ae70617 original
robert
parents:
diff changeset
543 )
a6b55ae70617 original
robert
parents:
diff changeset
544
a6b55ae70617 original
robert
parents:
diff changeset
545 [8] => SimpleXMLElement Object
a6b55ae70617 original
robert
parents:
diff changeset
546 (
a6b55ae70617 original
robert
parents:
diff changeset
547 [@attributes] => Array
a6b55ae70617 original
robert
parents:
diff changeset
548 (
a6b55ae70617 original
robert
parents:
diff changeset
549 [Name] => Timestamp
a6b55ae70617 original
robert
parents:
diff changeset
550 [Value] => 2016-12-15T23:12:34Z
a6b55ae70617 original
robert
parents:
diff changeset
551 )
a6b55ae70617 original
robert
parents:
diff changeset
552
a6b55ae70617 original
robert
parents:
diff changeset
553 )
a6b55ae70617 original
robert
parents:
diff changeset
554
a6b55ae70617 original
robert
parents:
diff changeset
555 [9] => SimpleXMLElement Object
a6b55ae70617 original
robert
parents:
diff changeset
556 (
a6b55ae70617 original
robert
parents:
diff changeset
557 [@attributes] => Array
a6b55ae70617 original
robert
parents:
diff changeset
558 (
a6b55ae70617 original
robert
parents:
diff changeset
559 [Name] => Version
a6b55ae70617 original
robert
parents:
diff changeset
560 [Value] => 2011-08-01
a6b55ae70617 original
robert
parents:
diff changeset
561 )
a6b55ae70617 original
robert
parents:
diff changeset
562
a6b55ae70617 original
robert
parents:
diff changeset
563 )
a6b55ae70617 original
robert
parents:
diff changeset
564
a6b55ae70617 original
robert
parents:
diff changeset
565 [10] => SimpleXMLElement Object
a6b55ae70617 original
robert
parents:
diff changeset
566 (
a6b55ae70617 original
robert
parents:
diff changeset
567 [@attributes] => Array
a6b55ae70617 original
robert
parents:
diff changeset
568 (
a6b55ae70617 original
robert
parents:
diff changeset
569 [Name] => Signature
a6b55ae70617 original
robert
parents:
diff changeset
570 [Value] => SUXfFZHQ74Joc+WDLx87uzemTdtHijNohykqafJXYKQ=
a6b55ae70617 original
robert
parents:
diff changeset
571 )
a6b55ae70617 original
robert
parents:
diff changeset
572
a6b55ae70617 original
robert
parents:
diff changeset
573 )
a6b55ae70617 original
robert
parents:
diff changeset
574
a6b55ae70617 original
robert
parents:
diff changeset
575 )
a6b55ae70617 original
robert
parents:
diff changeset
576
a6b55ae70617 original
robert
parents:
diff changeset
577 )
a6b55ae70617 original
robert
parents:
diff changeset
578
a6b55ae70617 original
robert
parents:
diff changeset
579 [RequestProcessingTime] => 0.3518217620000000
a6b55ae70617 original
robert
parents:
diff changeset
580 )
a6b55ae70617 original
robert
parents:
diff changeset
581
a6b55ae70617 original
robert
parents:
diff changeset
582 [Items] => SimpleXMLElement Object
a6b55ae70617 original
robert
parents:
diff changeset
583 (
a6b55ae70617 original
robert
parents:
diff changeset
584 [Request] => SimpleXMLElement Object
a6b55ae70617 original
robert
parents:
diff changeset
585 (
a6b55ae70617 original
robert
parents:
diff changeset
586 [IsValid] => True
a6b55ae70617 original
robert
parents:
diff changeset
587 [ItemLookupRequest] => SimpleXMLElement Object
a6b55ae70617 original
robert
parents:
diff changeset
588 (
a6b55ae70617 original
robert
parents:
diff changeset
589 [IdType] => ASIN
a6b55ae70617 original
robert
parents:
diff changeset
590 [ItemId] => B004Q3Q3Y4
a6b55ae70617 original
robert
parents:
diff changeset
591 [ResponseGroup] => Array
a6b55ae70617 original
robert
parents:
diff changeset
592 (
a6b55ae70617 original
robert
parents:
diff changeset
593 [0] => ItemAttributes
a6b55ae70617 original
robert
parents:
diff changeset
594 [1] => Reviews
a6b55ae70617 original
robert
parents:
diff changeset
595 [2] => EditorialReview
a6b55ae70617 original
robert
parents:
diff changeset
596 [3] => OfferSummary
a6b55ae70617 original
robert
parents:
diff changeset
597 [4] => Offers
a6b55ae70617 original
robert
parents:
diff changeset
598 [5] => Images
a6b55ae70617 original
robert
parents:
diff changeset
599 [6] => AlternateVersions
a6b55ae70617 original
robert
parents:
diff changeset
600 [7] => SalesRank
a6b55ae70617 original
robert
parents:
diff changeset
601 [8] => BrowseNodes
a6b55ae70617 original
robert
parents:
diff changeset
602 )
a6b55ae70617 original
robert
parents:
diff changeset
603
a6b55ae70617 original
robert
parents:
diff changeset
604 [VariationPage] => All
a6b55ae70617 original
robert
parents:
diff changeset
605 )
a6b55ae70617 original
robert
parents:
diff changeset
606
a6b55ae70617 original
robert
parents:
diff changeset
607 [Errors] => SimpleXMLElement Object
a6b55ae70617 original
robert
parents:
diff changeset
608 (
a6b55ae70617 original
robert
parents:
diff changeset
609 [Error] => SimpleXMLElement Object
a6b55ae70617 original
robert
parents:
diff changeset
610 (
a6b55ae70617 original
robert
parents:
diff changeset
611 [Code] => AWS.InvalidParameterValue
a6b55ae70617 original
robert
parents:
diff changeset
612 [Message] => B004Q3Q3Y4 is not a valid value for ItemId. Please change this value and retry your request.
a6b55ae70617 original
robert
parents:
diff changeset
613 )
a6b55ae70617 original
robert
parents:
diff changeset
614
a6b55ae70617 original
robert
parents:
diff changeset
615 )
a6b55ae70617 original
robert
parents:
diff changeset
616
a6b55ae70617 original
robert
parents:
diff changeset
617 )
a6b55ae70617 original
robert
parents:
diff changeset
618
a6b55ae70617 original
robert
parents:
diff changeset
619 )
a6b55ae70617 original
robert
parents:
diff changeset
620
a6b55ae70617 original
robert
parents:
diff changeset
621 )
a6b55ae70617 original
robert
parents:
diff changeset
622 */
21
46382face560 use a semaphore to try to cut down on RequestThrottled fails
Charlie Root
parents: 19
diff changeset
623 /*$xml = new SimpleXMLElement("<?xml version=\"1.0\"?><ItemLookupErrorResponse xmlns=\"http://ecs.amazonaws.com/doc/2009-03-31/\"><Error><Code>AccountLimitExceeded</Code><Message>Account limit of 2056 requests per hour exceeded.</Message></Error><RequestID>290ed059-730c-4789-93b4-6d21e11053d3</RequestID></ItemLookupErrorResponse>");*/
4
a6b55ae70617 original
robert
parents:
diff changeset
624 ?>