You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To determine valid categories for search call GetValidSearchNames() :
72
+
#### Default sort
73
+
74
+
By default, the `ItemSearch` method will search by featured. If you want to sort by another category then pass a 3rd parameter with the name of the category you wish to sort by. These differ by category type but the two you'll probably need are `price` (sort by price low to high) or `-price` (sort by price high to low). See [ItemSearch Sort Values](http://docs.aws.amazon.com/AWSECommerceService/latest/DG/APPNDX_SortValuesArticle.html) for more details.
75
+
76
+
```php
77
+
// Search for harry potter items in Books category, sort by low to high
By default the data will be returned as SimpleXML nodes. However if you call `SetRetrieveAsArray()` then a simplified array of items will be returned. For example:
93
105
94
106
```php
95
107
// Return XML data
96
-
$amazonAPI = new AmazonAPI($keyId, $secretKey, $associateId);
97
-
$items = $amazonAPI->ItemSearch('harry potter');
98
-
var_dump($items);
108
+
$amazonAPI = new AmazonAPI($keyId, $secretKey, $associateId);
109
+
$items = $amazonAPI->ItemSearch('harry potter');
110
+
var_dump($items);
99
111
```
100
112
101
113
This will output:
@@ -115,10 +127,10 @@ class SimpleXMLElement#2 (2) {
115
127
116
128
```php
117
129
// Return simplified data
118
-
$amazonAPI = new AmazonAPI($keyId, $secretKey, $associateId);
130
+
$amazonAPI = new AmazonAPI($keyId, $secretKey, $associateId);
119
131
$amazonAPI->SetRetrieveAsArray();
120
-
$items = $amazonAPI->ItemSearch('harry potter');
121
-
var_dump($items);
132
+
$items = $amazonAPI->ItemSearch('harry potter');
133
+
var_dump($items);
122
134
```
123
135
124
136
Returning simplified data gives a PHP array
@@ -158,9 +170,15 @@ array(10) {
158
170
```
159
171
160
172
## TODO
173
+
161
174
* Need to make the simplified data less hardcoded!
162
175
* Make this a Composer package
163
176
* Add unit tests
164
177
165
178
## Thanks
179
+
166
180
This library uses code based on [AWS API authentication For PHP](http://randomdrake.com/2009/07/27/amazon-aws-api-rest-authentication-for-php-5/) by [David Drake](https://github.com/randomdrake).
0 commit comments