Amazon Product Advertising API:如何获取ItemLookup/Search的JSON响应

tho*_*inu 37 xml xslt amazon jsonp cors

我正试图从其ASIN获取亚马逊产品的细节.产品API允许使用Itemlookup ASIN,但返回值为XML.

我想从客户端调用Itemlookup,所以想做一个JSONP我找不到的电话.

我在网上发现了一些文章,JSON使用XSLT样式表将XML转换为格式:

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

我尝试使用这个python-amazon-product-api和这个例子,但我无法得到JSON回报.

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

我试图发送的请求是:

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
Run Code Online (Sandbox Code Playgroud)

请帮助获取JSON格式Amazon product API.欢迎任何建议.


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>
Run Code Online (Sandbox Code Playgroud)

Sas*_*aZd 5

尝试其中任何一个::

  1. Amazon JSON API - 这是一个ruby Web服务,用于传递请求并将响应转换为JSON.
  2. 尝试使用任何这些Javascript函数将您已有的XML转换为JSON:
    1. http://goessner.net/download/prj/jsonxml/
    2. http://davidwalsh.name/convert-xml-json
    3. http://www.fyneworks.com/jquery/xml-to-json/
    4. http://www.thomasfrank.se/xml_to_json.html

我自己试过thomasfrank.它很容易,效果很好:)