I am working with amazon api and have used code from online sources http://www.codediesel.com/php/accessing-amazon-product-advertising-api-in-php/.
I would like to get more than 10 product's detail when I make a search query using amazon api. I am aware about the amazon api policy of getting 10 data per call but is it possible to get more data by creating loop or something?
When I make a request I have assigned following parameteres
$parameters = array("Operation" => "ItemSearch",
"SearchIndex" => "Electronics",
"ResponseGroup" => "Images,ItemAttributes,EditorialReview,Offers ",
"ItemPage"=>"10",
"Keywords" => $search );
So even though I have asked for 10 pages of result, I am unsure of how to display data from every page (1 to 10 ) so in total I get 100 items when I make a query. I get following response when I try to make run the code:
SimpleXMLElement Object (
[Request] => SimpleXMLElement Object (
[IsValid] => True
[ItemSearchRequest] => SimpleXMLElement Object (
[ItemPage] => 10
[Keywords] => laptop
[ResponseGroup] => Array (
[0] => Images
[1] => ItemAttributes
[2] => EditorialReview
[3] => Offers
)
[SearchIndex] => Electronics
)
)
[TotalResults] => 3383691
[TotalPages] => 338370
[MoreSearchResultsUrl] => http://www.amazon.co.uk/gp/redirect.html?camp=2025&creative=12734&location=http%3A%2F%2Fwww.amazon.co.uk%2Fgp%2Fsearch%3Fkeywords%3Dlaptop%26url%3Dsearch-.................(and on)
)
Yes, you would need to loop through 10 times and appends an array or object. The AWS documentation says that ItemPage
is actually the page of results, so you would just need to page through it 10 times to get your 100 results.
AWS Documentation on ItemPage
:
http://docs.aws.amazon.com/AWSECommerceService/latest/DG/PagingThroughResults.html
$obj = new AmazonProductAPI();
$results = array();
for ($i=1;$i<=10;$i++) {
$parameters = array("Operation" => "ItemSearch",
"SearchIndex" => "Electronics",
"ResponseGroup" => "Images,ItemAttributes,EditorialReview,Offers ",
"ItemPage"=>$i,
"Keywords" => $search);
$results[] = $obj->searchProducts($parameters);
}
foreach ($results as $r) {
//do your stuff
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With