Mercurial > hg > ywww
comparison xml/getAmazonInfo.php @ 33:c9d9b76ecbf9
minor tidying
author | Charlie Root |
---|---|
date | Fri, 04 Jan 2019 11:35:59 -0500 |
parents | 8130865e9e82 |
children | 86f79bc1d142 |
comparison
equal
deleted
inserted
replaced
32:8130865e9e82 | 33:c9d9b76ecbf9 |
---|---|
7 'locale' =>$localeIn, //which server's products? available: ca,de,fr,jp,uk,us | 7 'locale' =>$localeIn, //which server's products? available: ca,de,fr,jp,uk,us |
8 //'mode' =>'books', //what product category? | 8 //'mode' =>'books', //what product category? |
9 'page' =>1, //first page to show (we are counting from 1 not 0) | 9 'page' =>1, //first page to show (we are counting from 1 not 0) |
10 //'search' =>'Machiavelli', //what to search for? | 10 //'search' =>'Machiavelli', //what to search for? |
11 'operation' =>'ItemLookup', //what to do? //ItemSearch | 11 'operation' =>'ItemLookup', //what to do? //ItemSearch |
12 // 'searchindex' =>'Books', //what product category for search? | 12 'searchindex' =>'Books', //what product category for search? |
13 'searchparameter' =>'ItemId', //what kind of search? | 13 'searchparameter' =>'ItemId', //what kind of search? |
14 'searchparameterdata'=>$isbn, //what to search for? | 14 'searchparameterdata'=>$isbn, //what to search for? |
15 //here some debugging flags you can put at the end of the URL to call this script with, like: '?show_array=true' | 15 //here some debugging flags you can put at the end of the URL to call this script with, like: '?show_array=true' |
16 'show_array' =>false, //debug: show complete incoming array? You can use this to see what other information Amazon is sending | 16 'show_array' =>false, //debug: show complete incoming array? You can use this to see what other information Amazon is sending |
17 'show_url' =>false, //debug: show XML request url to be send to Amazon? | 17 'show_url' =>false, //debug: show XML request url to be send to Amazon? |
45 return getAmazonDetRemote($go,$language,$locale,$loc, | 45 return getAmazonDetRemote($go,$language,$locale,$loc, |
46 $page,$operation,$searchparameter, | 46 $page,$operation,$searchparameter, |
47 $searchparameterdata, | 47 $searchparameterdata, |
48 $show_array,$show_url,$show_xml); | 48 $show_array,$show_url,$show_xml); |
49 } | 49 } |
50 catch (Exception $code) { | 50 catch (Exception $e) { |
51 $code=$e->getMessage(); | |
51 file_put_contents('/var/ywww/debug/phpDebug', | 52 file_put_contents('/var/ywww/debug/phpDebug', |
52 "Bang: $code $i\n",FILE_APPEND); | 53 "Bang: $code $i\n",FILE_APPEND); |
53 if ($code=='RequestThrottled') { | 54 if ($code=='RequestThrottled') { |
54 usleep(200000); // Try to reduce throttling until we get a | 55 usleep(200000); // Try to reduce throttling until we get a |
55 // principled solution in place | 56 // principled solution in place |
122 //this is the data that is used to form the request for AWS | 123 //this is the data that is used to form the request for AWS |
123 //this is the part that is search specific | 124 //this is the part that is search specific |
124 $parameters=array( | 125 $parameters=array( |
125 'Operation' =>$operation , | 126 'Operation' =>$operation , |
126 //'Keywords' =>urlencode($search) , | 127 //'Keywords' =>urlencode($search) , |
127 //'SearchIndex' =>$searchindex , //Books for example. | |
128 "$searchparameter"=>$searchparameterdata , | 128 "$searchparameter"=>$searchparameterdata , |
129 'ItemPage' =>$page , //which page? | 129 'ItemPage' =>$page , //which page? |
130 'AssociateTag' =>$Aassociates_id[$locale], | 130 'AssociateTag' =>$Aassociates_id[$locale], |
131 'ResponseGroup' =>'ItemAttributes,Reviews,EditorialReview,OfferSummary,Offers,Images,AlternateVersions,SalesRank,BrowseNodes' , //Small, Medium, Large or SellerListing,'BrowseNodes',// , | 131 'ResponseGroup' =>'ItemAttributes,Reviews,EditorialReview,OfferSummary,Offers,Images,AlternateVersions,SalesRank,BrowseNodes' , //Small, Medium, Large or SellerListing,'BrowseNodes',// , |
132 'ReviewSort' =>'-HelpfulVotes' | 132 'ReviewSort' =>'-HelpfulVotes' |
133 ); | 133 ); |
134 | 134 |
135 if (isset($searchindex) && $searchindex!='Books') { | |
136 // HST did this | |
137 // Used to be in $parameters init above, but | |
138 // that caused an error: | |
139 // If idType equals ASIN, SearchIndex cannot be present | |
140 //'SearchIndex' =>$searchindex , //Books for example. | |
141 $parameters['SearchIndex']=$searchindex; | |
142 } | |
135 $requestURI = $_SERVER['REQUEST_URI']; | 143 $requestURI = $_SERVER['REQUEST_URI']; |
136 $requestIP = $_SERVER['REMOTE_ADDR']; | 144 $requestIP = $_SERVER['REMOTE_ADDR']; |
137 // if ($requestIP=="173.161.113.65" || $requestIP=="141.8.132.25") { | |
138 // $delay=60; | |
139 // file_put_contents('/var/ywww/debug/phpDebug', | |
140 // "bad guy: $requestIP, $requestURI\n", | |
141 // FILE_APPEND); | |
142 // sleep($delay); | |
143 // # No, can't do this | |
144 // # return; # bomb! | |
145 // # 'Kung', sitting on my desk in the office while I'm at home, | |
146 // # is occasionally hitting xml/getAmazonInfo.php: | |
147 // # e.g. Losing: ItemLookupErrorResponse, RequestThrottled, 129.215.197.36, /xml/getAmazonInfo.php?searchparameterdata=075154454X&locale=uk | |
148 // # repeatedly, same params | |
149 // } | |
150 $ext=$Aserver[$locale]['ext']; | 145 $ext=$Aserver[$locale]['ext']; |
151 $file_data=$ext; | 146 $file_data=$ext; |
152 ksort($parameters); | 147 ksort($parameters); |
153 foreach ($parameters as $i=>$d) { | 148 foreach ($parameters as $i=>$d) { |
154 $file_data.='&'.$i.'='.$d; | 149 $file_data.='&'.$i.'='.$d; |