|
Post by turbov21 on Oct 9, 2007 16:36:16 GMT -5
A simple program for grabbing your Flickr image. It defaults to my feed. Also, this is my first real Run BASIC program, please be gentle. ' Fetch Flickr feed
cls
input "Enter your Flickr RSS 2.0 feed: "; url$
if len(url$) = 0 then url$ = "http://api.flickr.com/services/feeds/photos_public.gne?id=35034351103@N01&lang=en-us&format=rss_200" else url$ = url$
[fetch] cls
result$ = httpget$(url$)
if len(result$) > 0 then goto [parse] else goto [fail]
[parse] xmlparser #rss, result$
#channel = #rss #element(1)
for x = 1 to #channel elementCount()
#item = #channel #element(x)
if (#item key$() = "item") then
#link = #item #element(2) #mc = #item #element(8) pic$ = #mc attribValue$("url")
html "<p>" html "<a href=""" + #link value$() + """><img src=""" + pic$ + """ border=""0"" /></a>" html "</p>"
end if next x
wait
[fail] link #fail, "Try again", [fetch] wait
UPDATE: Fixed a small bug. UPDATE 2: Oh, oh, oh! Credit does to BASICwebmaster and Carl Grundel's RSS and XML examples (respectively) for helping me grok the parsing. UPDATE 3: Gundel. G-U-N-D-E-L! Eek.
|
|
|
Post by billw on Oct 9, 2007 17:12:50 GMT -5
Very nice! Knocks the socks off of the silly scripts and widgets they'd have you use.
|
|
|
Post by carlgundel on Oct 9, 2007 17:44:24 GMT -5
UPDATE 2: Oh, oh, oh! Credit does to BASICwebmaster and Carl Grundel's RSS and XML examples (respectively) for helping me grok the parsing. Who is Carl Grundel? Some sort of Beowolf-ian character? -Carl Gundel
|
|
|
Post by turbov21 on Oct 9, 2007 18:03:14 GMT -5
' Fetch Flickr feed
current = 1 rsslen = 0 rsscnt = 1
[start] cls html "<div style=""width:100%;text-align:center;"">" input "Enter your Flickr RSS 2.0 feed: "; url$ html "</div>"
[fetch] if len(url$) = 0 then url$ = "http://api.flickr.com/services/feeds/photos_public.gne?id=35034351103@N01&lang=en-us&format=rss_200" else url$ = url$
result$ = httpget$(url$)
if len(result$) > 0 then goto [parse] else goto [fail]
[parse] xmlparser #rss, result$
#channel = #rss #element(1) rsslen = #channel elementCount()
dim pics$(rsslen) dim urls$(rsslen)
for x = 1 to rsslen
#item = #channel #element(x)
if (#item key$() = "item") then
#link = #item #element(2) urls$(rsscnt) = #link value$()
#mc = #item #element(8) pics$(rsscnt) = #mc attribValue$("url")
rsscnt = rsscnt + 1
end if next x
[display] cls html "<div style=""width:100%;text-align:center;"">" print current Call ShowPic urls$(current) pics$(current) link #b, "Previous", [back] print " "; link #f, "Forward", [forward] print "" html "<p>" link #a, "Show All", [show all] html "</p>" html "</div>" wait
[forward] if current = rsscnt then current = 1 else current = current + 1 goto [display]
[back] if current = 1 then current = rsscnt -1 else current = current - 1 goto [display]
[fail] cls html "<div style=""width:100%;text-align:center;"">" link #fail, "Try again", [fetch] html "</div>" wait
[show all] cls html "<div style=""width:100%;text-align:center;"">" for piccy = 1 to rsscnt - 1
Call ShowPic urls$(piccy) pics$(piccy)
next piccy html "<p>" link #d, "Just Show One", [display] html "</p>" html "</div>" wait
Sub ShowPic Furl$ Fpic$ html "<p>" html "<a href=""" + Furl$ + """><img src=""" + Fpic$ + """ border=""0"" /></a>" html "</p>" End Sub
|
|
|
Post by turbov21 on Oct 9, 2007 18:03:48 GMT -5
Blushing as hard as I possibly can!
|
|
|
Post by carlgundel on Oct 9, 2007 18:17:40 GMT -5
That's fun. Thanks for that. Maybe it belongs on the Wiki?
-Carl
|
|
|
Post by StefanPendl on Oct 11, 2007 1:38:37 GMT -5
I would rename the forward button to next, so one could not think he could forward the picture to somewhere
|
|
|
Post by turbov21 on Oct 11, 2007 11:58:45 GMT -5
I would rename the forward button to next, so one could not think he could forward the picture to somewhere I'll have to fix that. Thanks.
|
|