O'Reilly Hacks
oreilly.comO'Reilly NetworkSafari BookshelfConferences Sign In/My Account | View Cart   
Book List Learning Lab PDFs O'Reilly Gear Newsletters Press Room Jobs  


 
Buy the book!
Amazon Hacks
By Paul Bausch
August 2003
More Info

HACK
#54
List Your Items for Sale on Your Web Site
If you have your own web site, you can mirror your Amazon listings there so you can reach your audience as well
The Code
[Discuss (0) | Link to this hack]

The Code

This ASP script requests your latest items for sale on Amazon and formats them as a local web page. You'll need an Amazon developer's token to run the script, and you can include an affiliate tag. You'll also need to find your Seller ID and set it at the top of the code.

<%
  ' Set Associate ID, Developer Token, and Seller ID
  Const AFF_TAG = "insert associate tag"
  Const DEV_TOKEN = "insert developer token"
  Const SELLER_ID = "insert seller ID"
  
  XMLURL = "http://xml.amazon.com/onca/xml3" & _
           "?t=" + AFF_TAG & _
           "&dev-t=" + DEV_TOKEN & _
           "&SellerSearch=" + SELLER_ID & _
           "&type=heavy" & _
           "&page=1" & _
           "&offerstatus=open" & _
           "&f=xml"
          
  ' Issue the request and wait for the response
    Set xmlhttp = Server.CreateObject("Msxml2.SERVERXMLHTTP")
    xmlhttp.Open "GET", XMLURL, false
    xmlhttp.Send(Now)
    If Err.Number <> 0 Then
        response.write "Unable to connect to Amazon."
        response.end
    End If    

    Set XMLDoc = xmlhttp.responseXML
    'response.write "<xmp>" & XMLDoc.xml & "</xmp>"
    If XMLDoc.parseError.ErrorCode <> 0 Then
        response.write "Error: " & XMLDoc.parseError.reason
        response.end
    End If

    ' Look for the ErrorMsg tag
    Set XMLError = XMLDoc.SelectNodes("//ErrorMsg")
    
    ' If it exists, display the message and exit
    If XMLError.length > 0 Then
       response.write XMLDoc.SelectSingleNode("//ErrorMsg").text
       response.end
    End If

    ' If there's no error, loop through items for sale
    Set ProdDetail = XMLDoc.SelectNodes("//ListingProductDetails")
    For x = 0 To (ProdDetail.length - 1)
      strExID = ProdDetail(x).selectSingleNode("ExchangeID").text
      strTitle = ProdDetail(x).selectSingleNode("ExchangeTitle").text
      strPrice = ProdDetail(x).selectSingleNode("ExchangePrice").text
      strOffer = ProdDetail(x).selectSingleNode("ExchangeOfferingType").text
      response.write "<b>" & strTitle & "</b><br>"
      response.write strPrice & " (" & strOffer & ")"
      response.write "<br><br>" & vbCrLf
    Next
%>


O'Reilly Home | Privacy Policy

© 2007 O'Reilly Media, Inc.
Website: | Customer Service: | Book issues:

All trademarks and registered trademarks appearing on oreilly.com are the property of their respective owners.