kir*_*tel 7 php api amazon amazon-web-services
我正在使用amazon api并使用来自在线资源的代码http://www.codediesel.com/php/accessing-amazon-product-advertising-api-in-php/.
当我使用amazon api进行搜索查询时,我想获得超过10个产品的详细信息.我知道每次调用获得10个数据的amazon api策略,但是可以通过创建循环或其他东西获得更多数据吗?
当我提出请求时,我已经分配了以下参数
$parameters = array("Operation" => "ItemSearch",
"SearchIndex" => "Electronics",
"ResponseGroup" => "Images,ItemAttributes,EditorialReview,Offers ",
"ItemPage"=>"10",
"Keywords" => $search );
Run Code Online (Sandbox Code Playgroud)
因此,即使我要求10页的结果,我不确定如何显示每个页面(1到10)的数据,所以总共我得到100个项目,当我进行查询.当我尝试运行代码时,我得到以下响应:
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)
)
Run Code Online (Sandbox Code Playgroud)
小智 4
是的,您需要循环 10 次并附加一个数组或对象。AWS 文档称这ItemPage实际上是结果页面,因此您只需翻阅 10 次即可获得 100 个结果。
AWS 文档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
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4456 次 |
| 最近记录: |