<% '///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 'Example usage of script - FlickrTags2Google.asp?lat=11.511955&long=48.129893&tags=Oktoberfest_07&flickrID=7389734@N03 'TODO - Custom css ' - Size the map ' - Multipule pics in same loc Public picture_arr,intPhotoNum ReDim picture_arr(6, 20) Public strLat, strLong, strTags, strFlickrUser strLat = Request.QueryString("lat") strLong = Request.QueryString("long") strTags = Request.QueryString("tags") strFlickrUser = Request.Querystring("flickrID") 'make sure the lat and long are passed If (strLat = "" or strLong = "") then Response.write "No latitude or longitude starting points passed!!
" Response.end end if if strTags = "" then response.write "No Flickr tags passed!!
" response.end end if if strFlickrUser = "" then response.write "No Flickr UserID passed!!
" response.end end if %> Oktoberfest Map
<% response.write intPhotoNum %> <% '/////////////////////////////////////////////////////////////////////////////////// 'Fucntion to get all of the photos out of the xml 'from flickr, then pass the photo_id to the GetPhotoDetails 'function that will in turn get us back the long/lat and other details of the photo Function getFlickrXML(flickrUrl) dim xmlhttp set xmlhttp = Server.CreateObject("Microsoft.XMLHTTP") xmlhttp.Open "GET", flickrUrl, false xmlhttp.Send set source1 = Server.CreateObject("Microsoft.XMLDOM") Set objLst = Server.CreateObject("Microsoft.XMLDOM") source1.async = false source1.setProperty "SelectionLanguage", "XPath" source1.loadxml(xmlhttp.ResponseText) pstrXPath = "/rsp/photos/photo" Set pobjNodeList = source1.selectNodes(pstrXPath) intPhotoNum = 0 For Each pobjNode in pobjNodeList 'Now we have the photos, call the fucntion to extract the data out of each one so we can see it on the map GetPhotoDetails pobjNode.getAttribute("id"), intPhotoNum intPhotoNum = intPhotoNum + 1 Next 'Re dimenstion the array to the correct size. The number of pics minus one, due to the array being zero based Redim Preserve picture_arr(6,intPhotoNum -1) 'kill the objects Set pobjNode = Nothing Set pobjNodeList = Nothing Set source1 = Nothing End Function %> <% Function GetPhotoDetails (flickr_photo_id, intPhotoNum) dim xmlhttp_pic set xmlhttp_pic = Server.CreateObject("Microsoft.XMLHTTP") xmlhttp_pic.Open "GET", "http://www.flickr.com/services/rest/?method=flickr.photos.getInfo&api_key=a7450eaf4f4b31f914de034d136293a1&photo_id=" & flickr_photo_id, false xmlhttp_pic.Send set pic_source = Server.CreateObject("Microsoft.XMLDOM") Set pic_objLst = Server.CreateObject("Microsoft.XMLDOM") pic_source.async = false pic_source.setProperty "SelectionLanguage", "XPath" pic_source.loadxml(xmlhttp_pic.ResponseText) PicXPath = "/rsp/photo/tags/tag" Set pic_objNodeList = pic_source.selectNodes(PicXPath) 'if we find a long and lat, set the checker flags to 1 and 1 For Each pic_pobjNode in pic_objNodeList 'check the tags if instr(pic_pobjNode.getAttribute("raw"), "geo:lat=") then strLat = Mid(pic_pobjNode.getAttribute("raw"), instr(pic_pobjNode.getAttribute("raw"), "=")+1, len(pic_pobjNode.getAttribute("raw")) - instr(pic_pobjNode.getAttribute("raw"),"=")+ 1) picture_arr( 1, intPhotoNum ) = strLat elseif instr(pic_pobjNode.getAttribute("raw"), "geo:lon=") then strLon = Mid(pic_pobjNode.getAttribute("raw"), instr(pic_pobjNode.getAttribute("raw"), "=")+1, len(pic_pobjNode.getAttribute("raw")) - instr(pic_pobjNode.getAttribute("raw"),"=")+ 1) picture_arr( 0, intPhotoNum ) = strLon end if Next 'if the checker flags are both good, get the rest of the picture info out of the XML if (strLat <> "" and strLon <> "") then 'if we have got here extract the picture details. The title, the description, the image url and the href back to Flickr PicXPath = "/rsp/photo/title" Set pic_objNodeList = pic_source.selectNodes(PicXPath) For Each pic_pobjNode in pic_objNodeList picture_arr(2, intPhotoNum ) = pic_pobjNode.Text next PicXPath = "/rsp/photo/description" Set pic_objNodeList = pic_source.selectNodes(PicXPath) For Each pic_pobjNode in pic_objNodeList picture_arr(3, intPhotoNum ) = pic_pobjNode.Text next 'make sure there is something in there if picture_arr(3, intPhotoNum ) = "" then picture_arr(3, intPhotoNum ) = "No description" 'now work out the img source and the flickr url PicXPath = "/rsp/photo" Set pic_objNodeList = pic_source.selectNodes(PicXPath) For Each pic_pobjNode in pic_objNodeList 'build the img source url strImgSrc = "http://farm" & pic_pobjNode.getAttribute("farm") & ".static.flickr.com/" & pic_pobjNode.getAttribute("server") & "/" &_ pic_pobjNode.getAttribute("id") & "_" & pic_pobjNode.getAttribute("secret") & "_m.jpg" picture_arr(4, intPhotoNum ) = strImgSrc next 'build the href PicXPath = "/rsp/photo/urls/url" Set pic_objNodeList = pic_source.selectNodes(PicXPath) For Each pic_pobjNode in pic_objNodeList picture_arr(5, intPhotoNum ) = pic_pobjNode.Text next 'build the date/time it was taken PicXPath = "/rsp/photo/dates" Set pic_objNodeList = pic_source.selectNodes(PicXPath) For Each pic_pobjNode in pic_objNodeList 'work out the date/time in a better format strTmpTaken = pic_pobjNode.getAttribute("taken") strTakenString = "Taken : " & Mid(strTmpTaken, 9,2) & "/" & Mid(strTmpTaken, 6,2) & "/" & Left(strTmpTaken,4) & " at " & Mid(strTmpTaken, 12,8) picture_arr(6, intPhotoNum ) = strTakenString next end if Set pic_pobjNode = Nothing Set pic_objNodeList = Nothing Set pic_source = Nothing End Function %>