<% Option explicit Dim i, reqISBN fm_HeadLayout("Amazon::API") reqISBN = Trim(Request.Querystring("ISBN")) If reqISBN="" Then %>
Add New Book;
ISBN :
013047729X
<% Else '// Return Variables Dim refISBN, refName, refDate, refPublisher, refImage, refListPrice, refOurprice, refUsedPrice, refSalesrank, refDescription, refAvgRating '// Arrays Dim refCategories(), refAuthors() '// Make Request getAmazon reqISBN,"","","","","","","","", refCategories, refAuthors End If fm_FooterLayout '// Get book information from Amazon by Heavy XML Function getAmazon(byVal ISBN, byRef refISBN, byRef refName, byRef refDate, byRef refPublisher, byRef refImage, byRef refSalesRank, byRef refDesciption, byRef refAvgRating, byRef refCategories, byRef refAuthors) '// Amazon Associates ID Const amazonID = "YOURUSERNAME" '// Amazon Developer Token Const devToken = "YOUR AMAZON DEV TOKEN" '// Amazon XML Server Const amazonServer = "http://xml.amazon.com/onca/xml3?" '// Amazon XML Consts Const XMLProductName = "ProductName" Const XMLCatalog = "Catalog" Const XMLAuthors = "Authors" Const XMLReleaseDate = "ReleaseDate" Const XMLManufacturer = "Manufacturer" Const XMLImage = "ImageUrlMedium" 'ImageUrlSmall 'ImageUrlMedium 'ImageUrlLarge Const XMLListPrice = "ListPrice" Const XMLOurPrice = "OurPrice" Const XMLUsedPrice = "UsedPrice" Const XMLThirdPartyPrice = "ThirdPartyNewPrice" Const XMLSalesRank = "SalesRank" Const XMLBrowseList = "BrowseList" Const XMLMedia = "Media" Const XMLNumedia = "NumMedia" Const XMLISBN = "Isbn" Const XMLAvailability = "Availability" Const XMLProductDescription = "ProductDescription" Const XMLReviews = "Reviews" Const XMLAvgCustomerRating = "AvgCustomerRating" Const XMLSimiliarProducts = "SimilarProducts" '// Base URL Dim URL, method, XMLtype, result method ="GET" XMLtype = "heavy" URL = amazonServer & "t=" & amazonID & "&dev-t=" & devToken & "&" '// Request Paramaters Dim arrParams arrParams = Array ("page","1","f","xml","mode","books","type",XMLtype) '// Add ISBN fm_AddNew2Arr arrParams, "AsinSearch" fm_AddNew2Arr arrParams, ISBN '// Build Final URL For i=0 To Ubound(arrParams) Step 2 URL = URL & "&" & arrParams(i) & "=" & arrParams(i+1) Next '// amazonResult result = makeRequest(URL,method) '// XML Object Dim objXML, objLst Dim objXMLnodes, objXMLroot Set objXML = CreateObject("Microsoft.XMLDOM") objXML.async = false '// Load Returned String as XML objXML.LoadXML result '// Set real node as root Set objXMLroot = objXML.selectSingleNode("ProductInfo").selectSingleNode("Details") '// Set Returns ! refISBN = objXMLroot.selectSingleNode(XMLISBN).Text refName = objXMLroot.selectSingleNode(XMLProductName).Text refDate = objXMLroot.selectSingleNode(XMLReleaseDate).Text refPublisher = objXMLroot.selectSingleNode(XMLManufacturer).Text refImage = objXMLroot.selectSingleNode(XMLImage).Text refDescription = objXMLroot.selectSingleNode(XMLProductDescription).Text refSalesRank = objXMLroot.selectSingleNode(XMLSalesRank).Text ' refAvgRating = objXMLroot.selectSingleNode(XMLImage).selectSingleNode(XMLAvgCustomerRating).Text '// Categories ! ' Set objXMLnodes = objXMLroot.childNodes.Item(i) ' fm_AddNew2Arr refCategories, For i=0 To objXMLroot.childNodes.Length - 1 ' Set objXMLnodes = objXMLroot.childNodes.Item(i) ' Response.Write objXMLnodes.nodeName & "
" Next '// For Debug 'For i=0 To objXMLroot.childNodes.Length - 1 ' Set objXMLnodes = objXMLroot.childNodes.Item(i) ' Response.Write objXMLnodes.nodeName & "
" 'Next Response.WRite "
" & fm_Encode(result) & "
" End Function Function fm_HeadLayout(byVal title) footTimer = Timer ' "ol{margin:4px 4px 20px 4px}" &_ Response.Write ""&_ "" &_ "" &_ "" &_ "" &_ "" & Title & "" &_ ""&_ "" &_ "

" & Title & "


" End Function Function fm_FooterLayout() Response.Write ""&_ "
by Ferruh Mavituna" &_ "
Proc.Time : " & fm_Timer(Timer-footTimer) &_ "" End Function '****************************************************************** '// fm_Timer v1.5 by Ferruh Mavituna '****************************************************************** '//NFO// ' Make clock timer format '//ARGUMENTS// ' timex : Time as Second '//RETURN// 'Some String Like 00:15 '//SAMPLE// ' Response.Write P13_Timer(timer) '****************************************************************** Function fm_Timer(timex) Dim mn, sc, mntxt, sctxt If isnumeric(timex) Then '// Format Minute mn = Round(timex/60,0) if mn < 0 Then mn = 0 if mn < 10 Then mntxt = "0" mntxt = mntxt & mn '// Format Second sc = Round(timex Mod 60,0) if sc < 0 Then sc = 0 if sc < 10 Then sctxt = "0" sctxt = sctxt & sc '// Final fm_Timer = mntxt & ":" & sctxt Else fm_Timer = "Error value is not numeric !" End If End function '// FM AddNew2Arr() v0.2 '// Array Pusher '// Array size must be "0" or so.. '// 05.10.2003 '******************************************************* Function fm_AddNew2Arr(byRef Arr, byVal Data) ' Response.Write Ubound(Arr) Redim Preserve Arr(Ubound(Arr)+1) Arr(Ubound(Arr)) = Data ' Response.Write Ubound(Arr) ' Response.Write "
" End Function Function fm_DumpArr(byVal Arr) If NOT IsArray(Arr) Then Exit Function Dim i For i = 0 To Ubound(Arr) Response.Write i & ") " & Arr(i) & "
" Next End Function Function makeRequest(byval URL, byVal method) Dim Xobj, Code Set Xobj = Server.CreateObject("Msxml2.XMLHTTP") Xobj.Open method,Url,false Xobj.Send makeRequest = Xobj.ResponseText '// Kill Set Xobj = Nothing End Function %>