ASP - Amazon Web Services Sample
10.07.2005
Okuyucu : 3.021
Günlük Okuyucu : 2,9
Okuyucu : 3.021
Günlük Okuyucu : 2,9
Simple ASP - Amazon Web Services Demo source code.
Kaynak Kodunu Download Edin (Download Source Code);
/opensource/source-code/fm-amazon.txt
Kaynak Kod;
1 : <%
2 : Option explicit
4 : Dim i, reqISBN
5 : fm_HeadLayout("Amazon::API")
6 : reqISBN = Trim(Request.Querystring("ISBN"))
9 : If reqISBN="" Then
10 : %>
11 : <form name="isbn" method="get" action="<%=fm_thispage%>">
12 : <fieldset>
13 : <legend>Add New Book;</legend>
14 : <br />ISBN : <input type="text" name="isbn" id="isbn"> <input type="submit" value="OK" class="but"><br />
15 : 013047729X
16 : </fieldset>
17 : </form>
18 : <%
19 : Else
21 : '// Return Variables
22 : Dim refISBN, refName, refDate, refPublisher, refImage, refListPrice, refOurprice, refUsedPrice, refSalesrank, refDescription, refAvgRating
24 : '// Arrays
25 : Dim refCategories(), refAuthors()
27 : '// Make Request
28 : getAmazon reqISBN,"","","","","","","","", refCategories, refAuthors
30 : End If
32 : fm_FooterLayout
34 : '// Get book information from Amazon by Heavy XML
35 : Function getAmazon(byVal ISBN, byRef refISBN, byRef refName, byRef refDate, byRef refPublisher, byRef refImage, byRef refSalesRank, byRef refDesciption, byRef refAvgRating, byRef refCategories, byRef refAuthors)
37 : '// Amazon Associates ID
38 : Const amazonID = "YOURUSERNAME"
40 : '// Amazon Developer Token
41 : Const devToken = "YOUR AMAZON DEV TOKEN"
43 : '// Amazon XML Server
44 : Const amazonServer = "http://xml.amazon.com/onca/xml3?"
46 : '// Amazon XML Consts
47 : Const XMLProductName = "ProductName"
48 : Const XMLCatalog = "Catalog"
49 : Const XMLAuthors = "Authors"
50 : Const XMLReleaseDate = "ReleaseDate"
51 : Const XMLManufacturer = "Manufacturer"
52 : Const XMLImage = "ImageUrlMedium"
53 : 'ImageUrlSmall
54 : 'ImageUrlMedium
55 : 'ImageUrlLarge
56 :
57 : Const XMLListPrice = "ListPrice"
58 : Const XMLOurPrice = "OurPrice"
59 : Const XMLUsedPrice = "UsedPrice"
60 : Const XMLThirdPartyPrice = "ThirdPartyNewPrice"
61 : Const XMLSalesRank = "SalesRank"
62 : Const XMLBrowseList = "BrowseList"
63 : Const XMLMedia = "Media"
64 : Const XMLNumedia = "NumMedia"
65 : Const XMLISBN = "Isbn"
66 : Const XMLAvailability = "Availability"
67 : Const XMLProductDescription = "ProductDescription"
68 : Const XMLReviews = "Reviews"
69 : Const XMLAvgCustomerRating = "AvgCustomerRating"
71 : Const XMLSimiliarProducts = "SimilarProducts"
73 :
74 : '// Base URL
75 : Dim URL, method, XMLtype, result
76 : method ="GET"
77 : XMLtype = "heavy"
78 : URL = amazonServer & "t=" & amazonID & "&dev-t=" & devToken & "&"
80 : '// Request Paramaters
81 : Dim arrParams
82 : arrParams = Array ("page","1","f","xml","mode","books","type",XMLtype)
84 : '// Add ISBN
85 : fm_AddNew2Arr arrParams, "AsinSearch"
86 : fm_AddNew2Arr arrParams, ISBN
88 : '// Build Final URL
89 : For i=0 To Ubound(arrParams) Step 2
90 : URL = URL & "&" & arrParams(i) & "=" & arrParams(i+1)
91 : Next
92 :
93 : '// amazonResult
94 : result = makeRequest(URL,method)
96 : '// XML Object
97 : Dim objXML, objLst
98 : Dim objXMLnodes, objXMLroot
100 : Set objXML = CreateObject("Microsoft.XMLDOM")
101 : objXML.async = false
103 : '// Load Returned String as XML
104 : objXML.LoadXML result
105 :
106 : '// Set real node as root
107 : Set objXMLroot = objXML.selectSingleNode("ProductInfo").selectSingleNode("Details")
108 :
109 : '// Set Returns !
110 : refISBN = objXMLroot.selectSingleNode(XMLISBN).Text
111 : refName = objXMLroot.selectSingleNode(XMLProductName).Text
112 : refDate = objXMLroot.selectSingleNode(XMLReleaseDate).Text
113 : refPublisher = objXMLroot.selectSingleNode(XMLManufacturer).Text
114 : refImage = objXMLroot.selectSingleNode(XMLImage).Text
115 : refDescription = objXMLroot.selectSingleNode(XMLProductDescription).Text
116 : refSalesRank = objXMLroot.selectSingleNode(XMLSalesRank).Text
117 : ' refAvgRating = objXMLroot.selectSingleNode(XMLImage).selectSingleNode(XMLAvgCustomerRating).Text
120 : '// Categories !
121 : ' Set objXMLnodes = objXMLroot.childNodes.Item(i)
123 : ' fm_AddNew2Arr refCategories,
125 : For i=0 To objXMLroot.childNodes.Length - 1
126 : ' Set objXMLnodes = objXMLroot.childNodes.Item(i)
127 : ' Response.Write objXMLnodes.nodeName & "<br />"
128 : Next
130 : '// For Debug
131 : 'For i=0 To objXMLroot.childNodes.Length - 1
132 : ' Set objXMLnodes = objXMLroot.childNodes.Item(i)
133 : ' Response.Write objXMLnodes.nodeName & "<br />"
134 : 'Next
135 : Response.WRite "<pre>" & fm_Encode(result) & "</pre>"
137 : End Function
140 : Function fm_HeadLayout(byVal title)
141 : footTimer = Timer
143 : ' "ol{margin:4px 4px 20px 4px}" &_
145 : Response.Write ""&_
146 : "<html>" &_
147 : "<head>" &_
148 : "<meta http-equiv=""content-Type"" content=""text/html; charset=windows-1254"" />" &_
149 : "<meta http-equiv=""Content-Type"" content=""text/html; charset=iso-8859-9"" />" &_
150 : "<title>" & Title & "</title>" &_
151 : "<style>"&_
152 : "body{background-color:#FFF;color:#333;margin:10px;font:11px Verdana;}" &_
153 : "input{color:#333;font:bold 11px Verdana;}" &_
154 : "#head{margin-bottom:15px;float:left; margin-right:20px;height:450px;}" &_
155 : "#main{text-align:left; width:700px}" &_
156 : "a {color:#FF00FF}a:hover{text-decoration:none;color:#F00}" &_
157 : ".prc{font:10px ""Microsoft Sans Serif"";color:#666}" &_
158 : "h1{font:20px Verdana ;color:#07F; margin:0px 0px 0px 0px}" &_
159 : "h2, legend{font:bold 14px Verdana;color:#C00;margin:0px}" &_
160 : "li{margin-bottom:10px}" &_
161 : "li a{text-decoration:none}" &_
162 : "hr{height:1px; margin:0px 0px 10px 0px;}" &_
163 : "fieldset{padding:20px;border-color:#FFF}" &_
164 : ".lform{width:130px;text-align:right;font-weight:bold}" &_
165 : ".li{width:300px}" &_
166 : "form{display:inline}" &_
167 : "a img{border:0px}" &_
168 : ".err{color:#F00};" &_
169 : "a.q{cursor:help}" &_
170 : "#foot {width:700px;}" &_
171 : "#foot a{color:#07F;}" &_
172 : "h1 em{color:#F00;font-variant:normal;}" &_
173 : "td{font:11px Verdana;} " &_
174 : ".tdh{font-size:12px;background-color:#F7F7F7;border-bottom:1px solid #CCC:text-align:center;padding:10px} " &_
175 : ".si{width:100px} " &_
176 : ".desc{border:1px dashed #CCC; background-color:#F7F7F7;padding:15px;font-family:Verdana;margin:10px} " &_
177 : "</style>"&_
178 : "</head>" &_
179 : "<h1>" & Title & "</h1><hr />"
180 : End Function
182 : Function fm_FooterLayout()
183 : Response.Write ""&_
184 : "<hr />by <a href=""http://ferruh.mavituna.com/cnt.asp"">Ferruh Mavituna</a>" &_
185 : "<br /><strong>Proc.Time :</strong> " & fm_Timer(Timer-footTimer) &_
186 : "</body></html>"
187 : End Function
190 : '******************************************************************
191 : '// fm_Timer v1.5 by Ferruh Mavituna
192 : '******************************************************************
193 : '//NFO//
194 : ' Make clock timer format
195 : '//ARGUMENTS//
196 : ' timex : Time as Second
197 : '//RETURN//
198 : 'Some String Like 00:15
199 : '//SAMPLE//
200 : ' Response.Write P13_Timer(timer)
201 : '******************************************************************
202 : Function fm_Timer(timex)
203 : Dim mn, sc, mntxt, sctxt
204 : If isnumeric(timex) Then
205 : '// Format Minute
206 : mn = Round(timex/60,0)
207 : if mn < 0 Then mn = 0
208 : if mn < 10 Then mntxt = "0"
209 : mntxt = mntxt & mn
211 : '// Format Second
212 : sc = Round(timex Mod 60,0)
213 : if sc < 0 Then sc = 0
214 : if sc < 10 Then sctxt = "0"
215 : sctxt = sctxt & sc
216 :
217 : '// Final
218 : fm_Timer = mntxt & ":" & sctxt
219 : Else
220 : fm_Timer = "Error value is not numeric !"
221 : End If
222 : End function
224 : '// FM AddNew2Arr() v0.2
225 : '// Array Pusher
226 : '// Array size must be "0" or so..
227 : '// 05.10.2003
228 : '*******************************************************
229 : Function fm_AddNew2Arr(byRef Arr, byVal Data)
230 : ' Response.Write Ubound(Arr)
231 :
232 : Redim Preserve Arr(Ubound(Arr)+1)
233 : Arr(Ubound(Arr)) = Data
235 : ' Response.Write Ubound(Arr)
236 : ' Response.Write "<br>"
237 : End Function
240 : Function fm_DumpArr(byVal Arr)
241 : If NOT IsArray(Arr) Then Exit Function
243 : Dim i
244 : For i = 0 To Ubound(Arr)
245 : Response.Write i & ") " & Arr(i) & "<br>"
246 : Next
247 : End Function
249 : Function makeRequest(byval URL, byVal method)
250 : Dim Xobj, Code
251 : Set Xobj = Server.CreateObject("Msxml2.XMLHTTP")
252 : Xobj.Open method,Url,false
253 : Xobj.Send
254 : makeRequest = Xobj.ResponseText
255 :
256 : '// Kill
257 : Set Xobj = Nothing
258 : End Function
260 : %>

Yorumlar
Aşağıdaki form aracılığı ile yorumlarınızı ve fikirlerinizi gönderebilirsiniz. Henüz bu konu hakkında bir yorum yazılmamış.
Yorum Ekle
Diğer Yazılar
ASP Auto-Linker
ASP' de hızlı string birleştirme
ASP Email Obfuscator
ASP ile Arama Eklentileri
ASP Secure Word Analizleri
ASP Template Sistemi
ASP ve ASP.NET arasında Session paylaşımı
ASP ve İbranice veya başka birşey...
ASP.NET / VB.NET ile Döviz Kurlarını Çekme (TCMB XML)
ASP.NET BreadCrumb Class' ı (Neredeyim? şeysi)
ASP.NET ile Döviz Kurlarını Çekme
ASP.NET ile geliştirme keyfi
ASP.NET Kod Örnekleri
ASP.NET Sayfa Çıktısını Yakalama
ASP.NET' te basit template mantığı
ASP.NET Web Deployment
ASPRunner Güvenlik Açıkları
ASPRunner Multiple Vulnerabilities
ASP-XML Entegrasyonu
Neredeyim ?
Ferruh.Mavituna » Kod Parçaları (Code Snippets) » ASP - Amazon Web Services Sample