Consuming Amazon Web Services in ASP and ASP.NET

Developers can now integrate Amazon content into their websites. This is done by consuming Amazon Web Services using XML-based protocols. The first thing a developer needs to do is to download the SDK and obtain a Developers Key. Visit the Amazon website:

http://www.amazon.com/webservices

Once Amazon has sent the Key, developers can tap into the web service by using some VB Script in an ASP page:

<%
 set xslt = createObject("MSXML2.XSLTemplate")
 set xslDoc = createObject("MSXML2.FreeThreadedDOMDocument")
 set xmlDoc = createObject("MSXML2.DOMDocument")
 xmlDoc.async = False
 xmlDoc.setProperty "ServerHTTPRequest", true
 xmlDoc.load(AmazonXmlUrl)
 xslDoc.async = False
 xslDoc.Load Server.MapPath("amazon_product_list.xsl")
 Set xslt.stylesheet = xslDoc
 Set xslProc = xslt.createProcessor()
 xslProc.input = xmlDoc
 xslProc.Transform
 
 function AmazonXmlUrl
 SearchString="Dreamweaver MX" 'Enter keywords to search for
 DeveloperKey="xxxxxxxx" 'You developer Key
 AffiliateID="webservices-20" 'Your affiliateID or use the default
 AmazonXmlUrl="http://xml.amazon.com/onca/xml?v=1.0&t=" & AffiliateID &_
 "&dev-t=" & DeveloperKey & "&KeywordSearch=" &_ 
 SearchString & "&mode=books&type=lite&page=1&f=xml"
 end function
 
 response.write xslProc.output
%>

The XSL file called amazon_product_list.xsl is contained in the support files and can be downloaded by clicking the link below. The XSL file contains a basic template to show the content from Amazon. This can be amended to suit the look and feel of a website. Other variables are:

C# in an ASPX page can also be used:

<%@ Page Language="C#" ContentType="text/html" ResponseEncoding="iso-8859-1" %>
<script runat="server">
 private void Page_Load(object sender, System.EventArgs e)
 {
  try
  {
   System.Xml.XmlDocument d=new System.Xml.XmlDocument();
   d.Load(new System.Xml.XmlTextReader(AmazonXmlUrl()));
   rss.Document=d;
   rss.TransformSource="amazon_product_list.xsl";  
  }
  catch
  {
   //
  }
 }
 
 private string AmazonXmlUrl()
 {
 string SearchString="Dreamweaver MX" ;
 string DeveloperKey="xxxxxxxxxx" ;
 string AffiliateID="webservices-20" ;
 return "http://xml.amazon.com/onca/xml?v=1.0&t=" + AffiliateID 
+ "&dev-t=" + DeveloperKey + "&KeywordSearch="
+ SearchString + "&mode=books&type=lite&page=1&f=xml"; } </script>
Download file
AddThis Social Bookmark Button

Related Links

Extensions About me Articles Downloads Portfolio

Products

Charon Cart 3 Extension Charon Cart.NET v2 Multi-lingual Application Charon Cart 2 Extension