2016-09-27 97 views
0

在我的web应用程序做亚马逊API“ItemLookup的要求,得到响应,比如我想获得在amazon.com上的“iPhone 7”所有可用ASINs,我的要求是这样的:亚马逊API ItemLookup响应解析

public class Application { 
    public static void main(String[] args) { 
     List<String> foundASINs = new ArrayList<>(); 
     Map<String, String> params = new HashMap<>(); 
     params.put("Operation", "ItemSearch"); 
     params.put("ResponseGroup", "ItemIds"); 
     params.put("Keywords", "iphone 7"); 
     params.put("SearchIndex", "Wireless"); 
     AwsRequest request = new AwsRequest(); 
     String res=""; 
     try { 
      request.getRequest(params); 

和AwsRequest类:

public Document getRequest (Map<String, String> params) throws IOException, NoSuchAlgorithmException, InvalidKeyException, ParserConfigurationException, SAXException { 
     params.put("Service", "AWSECommerceService"); 
     params.put("AssociateTag", ASSOCIATE_TAG); 
     params.put("Version", "2016-09-27"); 

     SignedRequestsHelper helper = SignedRequestsHelper.getInstance(ENDPOINT, AWS_ACCESS_KEY_ID, AWS_SECRET_KEY); 
     String requestUrl = helper.sign(params); 
     DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); 
     DocumentBuilder db = dbf.newDocumentBuilder(); 
     doc = db.parse(requestUrl); 
     return doc; 
    } 

所以我得到的响应为XML文档。 一切都好,但我想知道为什么我得到最多10个ASIN?如果我检查文档的TotalResults属性,必须有10000个以上的结果,但是作为回应,我只能看到10个结果?我怎样才能得到别人?

回答

0

它是amazon API限制的一部分,每页只能接收10个项目,最多10个页面。所以前100名,但你可以改变你的搜索获得更多,但不是没有额外的搜索。