2016-09-27 102 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名,但你可以改變你的搜索獲得更多,但不是沒有額外的搜索。