简体   繁体   English

亚马逊产品广告 API:如何获取 ItemLookup/Search 的 JSON 响应

[英]Amazon Product Advertising API : How to get a JSON response for ItemLookup/Search

I'm trying to get the details of Amazon product from its ASIN.我正在尝试从其 ASIN 获取亚马逊产品的详细信息。 The product API allows to do a Itemlookup with ASIN , but the return value is in XML .产品 API 允许使用ASIN进行 Itemlookup,但返回值是XML

I want to do this call for Itemlookup from client side, so would like to do a JSONP call, which I couldn't find.我想从客户端调用 Itemlookup,所以想做一个JSONP调用,但我找不到。

I found some articles on the web to convert the XML to JSON format using XSLT stylesheet:我在网上找到了一些使用XSLT样式表将XML转换为JSON格式的文章:

(a) https://bitbucket.org/basti/python-amazon-product-api/src/tip/examples/json-results.py (a) https://bitbucket.org/basti/python-amazon-product-api/src/tip/examples/json-results.py

I tried using this python-amazon-product-api and this example, but I couldn't get a JSON return.我尝试使用此python-amazon-product-api和此示例,但无法获得JSON返回。

(b) http://www.kokogiak.com/gedankengang/2006/05/consuming-amazons-web-api-directly.html (b) http://www.kokogiak.com/gedankengang/2006/05/sumption-amazons-web-api-directly.html

The request I tried to send is:我尝试发送的请求是:

http://xml-us.amznxslt.com/onca/xml?AWSAccessKeyId=[ACCESS KEY]&AssociateTag=[ASSOCIATE TAG]&ContentType=text%2Fjavascript&IdType=ASIN&ItemId=B008IEGS9W&Operation=ItemLookup&ResponseGroup=Images%2CItemAttributes&Service=AWSECommerceService&Style=http%3A%2F%2Fforums.delphiforums.com%2Fdelphidocsz%2Famazon%2Fjson.xsl&Timestamp=2012-09-04T06%3A40%3A11Z&Signature=AGOqXvVSeMp3YyVkT4mGNXVx0cFGG%2Bh%2FdAebevbbF9o%3D

Please help with getting a JSON format with Amazon product API .请帮助使用Amazon product API获取 JSON 格式。 Any suggestions are welcome.欢迎任何建议。


The OP can run this style-sheet (input document not used) to determine his XSLT version. OP 可以运行此样式表(未使用输入文档)来确定他的 XSLT 版本。

<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:msxsl="urn:schemas-microsoft-com:xslt"
  exclude-result-prefixes="xsl msxsl">
<xsl:output method="html" indent="yes"/>

<xsl:template match="/">
  <html>
    <head><title>About your XSLT Processor</title></head> 
   <body>
     <ul>
       <li>xsl:version=<xsl:value-of select="system-property('xsl:version')" /></li>
       <li>xsl:vendor=<xsl:value-of select="system-property('xsl:vendor')" /></li>
       <li>xsl:vendor-url=<xsl:value-of select="system-property('xsl:vendor-url')" /></li>
       <li>xsl:product-name=<xsl:value-of select="system-property('xsl:product-name')" /></li>
       <li>xsl:product-version=<xsl:value-of select="system-property('xsl:product-version')" /></li>
       <li>xsl:is-schema-aware=<xsl:value-of select="system-property('xsl:is-schema-aware')" /></li>
       <li>xsl:supports-serialization=<xsl:value-of select="system-property('xsl:supports-serialization')" /></li>
       <li>xsl:supports-backwards-compatibility=<xsl:value-of select="system-property('xsl:supports-backwards-compatibility')" /></li>
       <li>msxsl:version=<xsl:value-of select="system-property('msxsl:version')" /></li>
     </ul>  
   </body>  
 </html>  
</xsl:template>

</xsl:stylesheet>

Try either of these ::尝试其中任何一个 ::

  1. Amazon JSON API - This is a ruby webservice to pass through requests and translate the responses to JSON. Amazon JSON API - 这是一个 ruby​​ 网络服务,用于传递请求并将响应转换为 JSON。
  2. Try any of these Javascript functions to convert the XML you already have into JSON :尝试这些 Javascript 函数中的任何一个将您已有的 XML 转换为 JSON :
    1. http://goessner.net/download/prj/jsonxml/ http://goessner.net/download/prj/jsonxml/
    2. http://davidwalsh.name/convert-xml-json http://davidwalsh.name/convert-xml-json
    3. http://www.fyneworks.com/jquery/xml-to-json/ http://www.fyneworks.com/jquery/xml-to-json/
    4. http://www.thomasfrank.se/xml_to_json.html http://www.thomasfrank.se/xml_to_json.html

I've tried thomasfrank myself.我自己试过 thomasfrank。 Its easy and works well :)它很容易而且效果很好:)

(disclosure) I'm Max and I'm a cofounder of Zinc (zinc.io). (披露)我是 Max,我是 Zinc (zinc.io) 的联合创始人。 Our API produces a JSON response for both pricing and the product details page.我们的 API 为定价和产品详细信息页面生成 JSON 响应。 Here's a typical response for ASIN details: https://www.dropbox.com/s/peccdc1m2j34e0d/B018QPI98A.json?dl=0 .以下是对 ASIN 详细信息的典型响应: https ://www.dropbox.com/s/peccdc1m2j34e0d/B018QPI98A.json ? dl =0 If you're interested, see here: docs.zincapi.com如果您有兴趣,请参阅此处:docs.zincapi.com

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM