Mercurial > hg > ywww
comparison php/read/getBookDetails.php @ 3:a5e5475bf357
fix ASIN pblm, add debugging
author | robert |
---|---|
date | Wed, 28 Dec 2016 12:48:18 +0000 |
parents | 45ae2aeb2b52 |
children | 077b0a0a3e6d |
comparison
equal
deleted
inserted
replaced
2:45ae2aeb2b52 | 3:a5e5475bf357 |
---|---|
21 } | 21 } |
22 return false; | 22 return false; |
23 } | 23 } |
24 } | 24 } |
25 | 25 |
26 global $out,$isbn; | |
26 if(isset($_GET['isbn'])){ | 27 if(isset($_GET['isbn'])){ |
27 $isbn = $_GET['isbn']; | 28 $isbn = $_GET['isbn']; |
28 if(isset($_GET['locale'])){ | 29 if(isset($_GET['locale'])){ |
29 $locale=$_GET['locale']; | 30 $locale=$_GET['locale']; |
30 | 31 |
170 } | 171 } |
171 | 172 |
172 $parameters=array( | 173 $parameters=array( |
173 'Operation' =>$operation , | 174 'Operation' =>$operation , |
174 'Keywords' =>urlencode($search) , | 175 'Keywords' =>urlencode($search) , |
175 'SearchIndex' =>$searchindex , //Books for example. | |
176 "$searchparameter"=>$searchparameterdata , | 176 "$searchparameter"=>$searchparameterdata , |
177 'ItemPage' =>$page , //which page? | 177 'ItemPage' =>$page , //which page? |
178 'AssociateTag' =>$Aassociates_id[$locale], | 178 'AssociateTag' =>$Aassociates_id[$locale], |
179 'ResponseGroup' =>'ItemAttributes,Images,SalesRank,BrowseNodes' | 179 'ResponseGroup' =>'ItemAttributes,Images,SalesRank,BrowseNodes' |
180 ); | 180 ); |
181 | 181 |
182 if ($searchindex!='Books') { | |
183 // HST did this | |
184 // Used to be in $parameters init above, but | |
185 // that caused an error: | |
186 // If idType equals ASIN, SearchIndex cannot be present | |
187 //'SearchIndex' =>$searchindex , //Books for example. | |
188 $parameters['SearchIndex']=$searchindex; | |
189 } | |
190 | |
191 | |
192 file_put_contents('/var/ywww/debug/phpDebug',"parms bd: ". | |
193 print_r($parameters,TRUE)."\n",FILE_APPEND); | |
182 | 194 |
183 $ext=$Aserver[$locale]['ext']; | 195 $ext=$Aserver[$locale]['ext']; |
184 $file_data=$ext; | 196 $file_data=$ext; |
185 ksort($parameters); | 197 ksort($parameters); |
186 foreach ($parameters as $i=>$d) { | 198 foreach ($parameters as $i=>$d) { |
199 $out = curl_exec($crl); | 211 $out = curl_exec($crl); |
200 curl_close($crl); | 212 curl_close($crl); |
201 | 213 |
202 //echo $out; | 214 //echo $out; |
203 | 215 |
216 if (preg_match("<Error>",$out)) { | |
217 $xml = new SimpleXMLElement($out); | |
218 $resName=$xml->getName(); | |
219 $code=$xml->Error->Code; | |
220 file_put_contents('/var/ywww/debug/phpDebug',"Losing gBD: $resName, ". | |
221 $xml->Error->Code."\n",FILE_APPEND); | |
222 } | |
223 else { | |
204 $xml = new SimpleXMLElement($out); | 224 $xml = new SimpleXMLElement($out); |
205 //use this xml to pull out the necessary information and save it | 225 //use this xml to pull out the necessary information and save it |
226 set_error_handler(function () { | |
227 global $out,$isbn; | |
228 file_put_contents('/var/ywww/debug/phpDebug', | |
229 "Caught one bd: ".$isbn, | |
230 FILE_APPEND); | |
231 file_put_contents('/var/ywww/debug/phpDebug', | |
232 print_r($out, TRUE)."\n", | |
233 FILE_APPEND); | |
234 } ); | |
206 | 235 |
207 $title=""; | 236 $title=""; |
208 $author=""; | 237 $author=""; |
209 $binding=""; | 238 $binding=""; |
210 $dewey=""; | 239 $dewey=""; |
221 $dewey = "null"; | 250 $dewey = "null"; |
222 $imageURL = $xml->Items->Item->MediumImage->URL; | 251 $imageURL = $xml->Items->Item->MediumImage->URL; |
223 $salesRank = $xml->Items->Item->SalesRank; | 252 $salesRank = $xml->Items->Item->SalesRank; |
224 $pubDate = $xml->Items->Item->ItemAttributes->PublicationDate; | 253 $pubDate = $xml->Items->Item->ItemAttributes->PublicationDate; |
225 $publisher = $xml->Items->Item->ItemAttributes->Publisher; | 254 $publisher = $xml->Items->Item->ItemAttributes->Publisher; |
226 | 255 restore_error_handler(); |
227 /*echo $title; | 256 /*echo $title; |
228 echo $author; | 257 echo $author; |
229 echo $binding; | 258 echo $binding; |
230 echo $dewey; | 259 echo $dewey; |
231 echo $imageURL; | 260 echo $imageURL; |
312 } | 341 } |
313 | 342 |
314 $output .= "</BookDetails>"; | 343 $output .= "</BookDetails>"; |
315 | 344 |
316 echo $output; | 345 echo $output; |
346 } | |
317 } | 347 } |
318 ?> | 348 ?> |