1 <%@ Control Language="vb" debug="true"%>
\r
2 <%@ Import Namespace="System.Xml" %>
\r
3 <script runat="server">
\r
5 public tags as string
\r
6 public flickrKey as String
\r
8 Protected Overrides Sub Render(writer as HTMLTextWriter)
\r
9 writer.WriteLine("<rows update_ui='true' offset='0'>")
\r
11 dim url as string = "http://api.flickr.com/services/rest/?method=flickr.photos.search"
12 dim cnt as integer = 0
14 url &= "&safe_search=1"
15 url &= "&tag_mode=all"
16 url &= "&sort=interestingness-desc"
17 url &= "&extras=date_taken,owner_name,geo,tags"
18 url &= "&tags=" & tags
19 url &= "&api_key=" & flickrKey
\r
21 Dim doc As XmlDocument = New XmlDocument()
\r
23 Dim root As XmlElement = doc.DocumentElement
\r
24 'writer.WriteLine(root.OuterXml)
\r
25 Dim photoNodes = root.GetElementsByTagName("photo")
\r
26 Dim node as object, photourl as string
\r
27 For Each node In photoNodes
\r
28 writer.WriteLine("<tr>")
\r
29 ' "_s" suffix specifies a 75x75 pixel format
30 photourl = "http://farm" & node.Attributes("farm").value & ".static.flickr.com/" & node.Attributes("server").value & "/" & node.Attributes("id").value & "_" & node.Attributes("secret").value & "_s.jpg"
31 writer.WriteLine(XmlStringCell(photourl))
\r
32 writer.WriteLine(XmlStringCell(node.Attributes("title").value))
\r
33 writer.WriteLine(XmlStringCell(node.Attributes("ownername").value))
\r
34 writer.WriteLine(XmlStringCell(node.Attributes("datetaken").value))
\r
35 writer.WriteLine(XmlStringCell(node.Attributes("tags").value))
\r
36 writer.WriteLine("</tr>")
\r
42 writer.WriteLine("</rows>")
\r
43 writer.WriteLine("<rowcount>" & cnt & "</rowcount>")
46 Public function XmlStringCell(value as object) as String
\r
47 XmlStringCell="<td>" & server.HTMLEncode(value) & "</td>"
\r