-
Notifications
You must be signed in to change notification settings - Fork 1
/
amazon_api_test.cfm
executable file
·88 lines (73 loc) · 3.46 KB
/
amazon_api_test.cfm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<!--- Just a proof of concept for an older version of Grapevinyl --->
<cfif isdefined("form.artist") and isdefined("form.album") and trim(form.artist) NEQ "" and trim(form.album) NEQ "">
<cfset amazonKey = "your_key_here">
<cfset artistURI = URLEncodedFormat(form.artist)>
<cfset albumURI = URLEncodedFormat(form.album)>
<cfoutput>
<form name="driver" action="#CGI.SCRIPT_NAME#" method="post">
artist<br>
<input name="artist" type="text" value="#form.artist#"><br/><br/>
album<br>
<input name="album" type="text" value="#form.album#"><br/><br/>
perceived rating<br/>
<select name="rating">
<cfif form.rating IS 1><option value="1" selected>1 - sucks</option><cfelse><option value="1">1 - sucks</option></cfif>
<cfif form.rating IS 2><option value="2" selected>2</option><cfelse><option value="2">2</option></cfif>
<cfif form.rating IS 3><option value="3" selected>3</option><cfelse><option value="3">3</option></cfif>
<cfif form.rating IS 4><option value="4" selected>4</option><cfelse><option value="4">4</option></cfif>
<cfif form.rating IS 5><option value="5" selected>5 - love it</option><cfelse><option value="5">5 - love it</option></cfif>
</select><br><br/>
tags (separated by spaces)<br>
<input type="text" name="tags" size="60" value="#form.tags#"><br/><br/>
<input type="submit" value="get album art">
</form>
</cfoutput>
<cfhttp
method="get"
url="http://webservices.amazon.com/onca/xml?Service=AWSECommerceService&SubscriptionId=#amazonKey#&Operation=ItemSearch&SearchIndex=Music&Artist=#artistURI#&Title=#albumURI#&ResponseGroup=Medium,Images"></cfhttp>
<cfset document = #XMLParse(cfhttp.FileContent)#>
<cfif NOT isdefined("document.XMLRoot.Items.Request.Errors.Error.Message.XMLText")>
<cfset itemroot = document.XMLRoot.Items.Item>
<cfset detailpageurl = itemroot.DetailPageURL.XMLText>
<cfif isdefined("itemroot.LargeImage")>
<cfset imgurl = itemroot.LargeImage.URL.XMLText>
<cfset imgheight = itemroot.LargeImage.Height.XMLText>
<cfset imgwidth = itemroot.LargeImage.Width.XMLText>
</cfif>
<cfset amazonartist = itemroot.ItemAttributes.Artist.XMLText>
<cfset amazonalbum = itemroot.ItemAttributes.Title.XMLText>
<cfset amazonreleasedate = itemroot.ItemAttributes.ReleaseDate.XMLText>
<cfset amazonlabel = itemroot.ItemAttributes.Label.XMLText>
<cfoutput>
<h2>#amazonartist#</h2>
<h3>#amazonalbum# (#left(amazonreleasedate,4)#)</h3>
<cfif isdefined("imgurl")>
<a href="#detailpageurl#"><img src="#imgurl#" width="#imgwidth#" height="#imgheight#" border="0"></a><br>
<cfelse>
could not find cover art for you. don't worry - you can try updating this any time in the future.
</cfif>
</cfoutput>
<cfelse>
could not find cover art for you. don't worry - you can try updating this any time in the future.
</cfif>
<cfelse>
<cfoutput>
<form name="driver" action="#CGI.SCRIPT_NAME#" method="post">
artist<br>
<input name="artist" type="text"><br/><br/>
album<br>
<input name="album" type="text"><br/><br/>
perceived rating<br/>
<select name="rating">
<option value="1">1 - sucks</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5 - love it</option>
</select><br><br/>
tags (separated by spaces)<br>
<input type="text" name="tags" size="60"><br/><br/>
<input type="submit" value="get album art">
</form>
</cfoutput>
</cfif>