annotate xml/amazonBookSearch.php @ 44:38d209611508

change includes to assume (contra previos ASSUMES) that we have .user.ini which adds /var/test to include_path
author Charlie Root
date Sun, 06 Jan 2019 07:17:03 -0500
parents dbc006408d2b
children da133c130c1d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6
077b0a0a3e6d remaining originals according to dependency walk
Robert Boland <robert@markup.co.uk>
parents:
diff changeset
1 <?php
077b0a0a3e6d remaining originals according to dependency walk
Robert Boland <robert@markup.co.uk>
parents:
diff changeset
2
44
38d209611508 change includes to assume (contra previos ASSUMES) that we have .user.ini which adds /var/test to include_path
Charlie Root
parents: 43
diff changeset
3 include_once "ywww/dlog.php";
43
dbc006408d2b ASSUMES we have SetEnv PHP_VALUE "include_path =.:/var/test/private:/var/test/ywww:/usr/share/php" in apache2/.../test.conf
Charlie Root
parents: 30
diff changeset
4
44
38d209611508 change includes to assume (contra previos ASSUMES) that we have .user.ini which adds /var/test to include_path
Charlie Root
parents: 43
diff changeset
5 include_once "doAmazonRequest.php";
43
dbc006408d2b ASSUMES we have SetEnv PHP_VALUE "include_path =.:/var/test/private:/var/test/ywww:/usr/share/php" in apache2/.../test.conf
Charlie Root
parents: 30
diff changeset
6
6
077b0a0a3e6d remaining originals according to dependency walk
Robert Boland <robert@markup.co.uk>
parents:
diff changeset
7 $Adefault=array(
077b0a0a3e6d remaining originals according to dependency walk
Robert Boland <robert@markup.co.uk>
parents:
diff changeset
8 'language' =>'en', //what language to render the page in
077b0a0a3e6d remaining originals according to dependency walk
Robert Boland <robert@markup.co.uk>
parents:
diff changeset
9 'locale' =>'us', //which server's products? available: ca,de,fr,jp,uk,us
077b0a0a3e6d remaining originals according to dependency walk
Robert Boland <robert@markup.co.uk>
parents:
diff changeset
10 'page' =>1, //first page to show (we are counting from 1 not 0)
077b0a0a3e6d remaining originals according to dependency walk
Robert Boland <robert@markup.co.uk>
parents:
diff changeset
11 'operation' =>'ItemSearch', //what to do? //ItemSearch
077b0a0a3e6d remaining originals according to dependency walk
Robert Boland <robert@markup.co.uk>
parents:
diff changeset
12 'searchindex' =>'Books', //what product category for search?
077b0a0a3e6d remaining originals according to dependency walk
Robert Boland <robert@markup.co.uk>
parents:
diff changeset
13 'searchparameter' =>'Keywords', //what kind of search?
077b0a0a3e6d remaining originals according to dependency walk
Robert Boland <robert@markup.co.uk>
parents:
diff changeset
14 'searchparameterdata'=>'Machiavelli', //what to search for?
077b0a0a3e6d remaining originals according to dependency walk
Robert Boland <robert@markup.co.uk>
parents:
diff changeset
15 //here some debugging flags you can put at the end of the URL to call this script with, like: '?show_array=true'
077b0a0a3e6d remaining originals according to dependency walk
Robert Boland <robert@markup.co.uk>
parents:
diff changeset
16 'show_url' =>false, //debug: show XML request url to be send to Amazon?
077b0a0a3e6d remaining originals according to dependency walk
Robert Boland <robert@markup.co.uk>
parents:
diff changeset
17 );
077b0a0a3e6d remaining originals according to dependency walk
Robert Boland <robert@markup.co.uk>
parents:
diff changeset
18
077b0a0a3e6d remaining originals according to dependency walk
Robert Boland <robert@markup.co.uk>
parents:
diff changeset
19 //for all parameters see if the user has overruled it or use the default
077b0a0a3e6d remaining originals according to dependency walk
Robert Boland <robert@markup.co.uk>
parents:
diff changeset
20 foreach ($Adefault as $i=>$d) {
077b0a0a3e6d remaining originals according to dependency walk
Robert Boland <robert@markup.co.uk>
parents:
diff changeset
21 $$i=isset($_GET[$i])?$_GET[$i]:$d;
077b0a0a3e6d remaining originals according to dependency walk
Robert Boland <robert@markup.co.uk>
parents:
diff changeset
22 }
077b0a0a3e6d remaining originals according to dependency walk
Robert Boland <robert@markup.co.uk>
parents:
diff changeset
23 //this is the data that is used to form the request for AWS
077b0a0a3e6d remaining originals according to dependency walk
Robert Boland <robert@markup.co.uk>
parents:
diff changeset
24 //this is the part that is search specific
077b0a0a3e6d remaining originals according to dependency walk
Robert Boland <robert@markup.co.uk>
parents:
diff changeset
25
077b0a0a3e6d remaining originals according to dependency walk
Robert Boland <robert@markup.co.uk>
parents:
diff changeset
26 $parameters=array(
077b0a0a3e6d remaining originals according to dependency walk
Robert Boland <robert@markup.co.uk>
parents:
diff changeset
27 'Operation' =>$operation ,
077b0a0a3e6d remaining originals according to dependency walk
Robert Boland <robert@markup.co.uk>
parents:
diff changeset
28 //'Keywords' =>urlencode($search) ,
077b0a0a3e6d remaining originals according to dependency walk
Robert Boland <robert@markup.co.uk>
parents:
diff changeset
29 'SearchIndex' =>$searchindex , //Books for example.
077b0a0a3e6d remaining originals according to dependency walk
Robert Boland <robert@markup.co.uk>
parents:
diff changeset
30 "$searchparameter"=>stripslashes($searchparameterdata),
077b0a0a3e6d remaining originals according to dependency walk
Robert Boland <robert@markup.co.uk>
parents:
diff changeset
31 'ItemPage' =>$page , //which page?
077b0a0a3e6d remaining originals according to dependency walk
Robert Boland <robert@markup.co.uk>
parents:
diff changeset
32 'AssociateTag' =>$Aassociates_id[$locale],
077b0a0a3e6d remaining originals according to dependency walk
Robert Boland <robert@markup.co.uk>
parents:
diff changeset
33 'MerchantId' =>'All',
077b0a0a3e6d remaining originals according to dependency walk
Robert Boland <robert@markup.co.uk>
parents:
diff changeset
34 'Availability' =>'Available',
077b0a0a3e6d remaining originals according to dependency walk
Robert Boland <robert@markup.co.uk>
parents:
diff changeset
35 'Condition' =>'All',
077b0a0a3e6d remaining originals according to dependency walk
Robert Boland <robert@markup.co.uk>
parents:
diff changeset
36 'ResponseGroup' =>'Images,ItemAttributes' , //Small, Medium, Large or SellerListing
077b0a0a3e6d remaining originals according to dependency walk
Robert Boland <robert@markup.co.uk>
parents:
diff changeset
37 );
077b0a0a3e6d remaining originals according to dependency walk
Robert Boland <robert@markup.co.uk>
parents:
diff changeset
38
43
dbc006408d2b ASSUMES we have SetEnv PHP_VALUE "include_path =.:/var/test/private:/var/test/ywww:/usr/share/php" in apache2/.../test.conf
Charlie Root
parents: 30
diff changeset
39
dbc006408d2b ASSUMES we have SetEnv PHP_VALUE "include_path =.:/var/test/private:/var/test/ywww:/usr/share/php" in apache2/.../test.conf
Charlie Root
parents: 30
diff changeset
40 try {
dbc006408d2b ASSUMES we have SetEnv PHP_VALUE "include_path =.:/var/test/private:/var/test/ywww:/usr/share/php" in apache2/.../test.conf
Charlie Root
parents: 30
diff changeset
41 $ret=doAmazonRequest($Aserver[$locale]['ext'],$parameters,3,'s',False);
6
077b0a0a3e6d remaining originals according to dependency walk
Robert Boland <robert@markup.co.uk>
parents:
diff changeset
42 }
43
dbc006408d2b ASSUMES we have SetEnv PHP_VALUE "include_path =.:/var/test/private:/var/test/ywww:/usr/share/php" in apache2/.../test.conf
Charlie Root
parents: 30
diff changeset
43 catch (Exception $e) {
dbc006408d2b ASSUMES we have SetEnv PHP_VALUE "include_path =.:/var/test/private:/var/test/ywww:/usr/share/php" in apache2/.../test.conf
Charlie Root
parents: 30
diff changeset
44 if ($e->getMessage()=='AWS.ECommerceService.NoExactMatches') {
dbc006408d2b ASSUMES we have SetEnv PHP_VALUE "include_path =.:/var/test/private:/var/test/ywww:/usr/share/php" in apache2/.../test.conf
Charlie Root
parents: 30
diff changeset
45 // Seems to be an 'OK' thing...
dbc006408d2b ASSUMES we have SetEnv PHP_VALUE "include_path =.:/var/test/private:/var/test/ywww:/usr/share/php" in apache2/.../test.conf
Charlie Root
parents: 30
diff changeset
46 $ret='<?xml version="1.0" ?><ItemSearchResponse xmlns="http://webservices.amazon.com/AWSECommerceService/2011-08-01"><OperationRequest><RequestId>0e41c74c-eeff-4f24-a761-9537cfebea21</RequestId></OperationRequest><Items><Request><IsValid>True</IsValid></Request><TotalResults>0</TotalResults><TotalPages>0</TotalPages></Items></ItemSearchResponse>';
dbc006408d2b ASSUMES we have SetEnv PHP_VALUE "include_path =.:/var/test/private:/var/test/ywww:/usr/share/php" in apache2/.../test.conf
Charlie Root
parents: 30
diff changeset
47 }
dbc006408d2b ASSUMES we have SetEnv PHP_VALUE "include_path =.:/var/test/private:/var/test/ywww:/usr/share/php" in apache2/.../test.conf
Charlie Root
parents: 30
diff changeset
48 else {
dbc006408d2b ASSUMES we have SetEnv PHP_VALUE "include_path =.:/var/test/private:/var/test/ywww:/usr/share/php" in apache2/.../test.conf
Charlie Root
parents: 30
diff changeset
49 $ret='<?xml version="1.0" ?><ItemSearchResponse xmlns="http://webservices.amazon.com/AWSECommerceService/2011-08-01"><OperationRequest><RequestId>0e41c74c-eeff-4f24-a761-9537cfebea21</RequestId></OperationRequest><Items><Request><IsValid>True</IsValid><Errors><Error><Code>'.$code.'</Code><Message>[lost]</Message></Error></Errors></Request><TotalResults>0</TotalResults><TotalPages>0</TotalPages></Items></ItemSearchResponse>';
dbc006408d2b ASSUMES we have SetEnv PHP_VALUE "include_path =.:/var/test/private:/var/test/ywww:/usr/share/php" in apache2/.../test.conf
Charlie Root
parents: 30
diff changeset
50 }
dbc006408d2b ASSUMES we have SetEnv PHP_VALUE "include_path =.:/var/test/private:/var/test/ywww:/usr/share/php" in apache2/.../test.conf
Charlie Root
parents: 30
diff changeset
51 }
dbc006408d2b ASSUMES we have SetEnv PHP_VALUE "include_path =.:/var/test/private:/var/test/ywww:/usr/share/php" in apache2/.../test.conf
Charlie Root
parents: 30
diff changeset
52 echo $ret;