Flickr photos in OpenACS/Tcl

Here is my code for showing my Flickr photos on the left side of my blog:
namespace eval flickr {}
namespace eval flickr::people {}

ad_proc flickr::api_key {} { return "<em>your api key here</em>" }

ad_proc flickr::people::findByUsername { username } { set doc [util_httpget [export_vars -base \ { { method flickr.people.findByUsername } { api_key [flickr::api_key] } username }]] set xml [xml_parse -persist $doc] set root [xml_doc_get_first_node $xml] set user [xml_node_get_first_child_by_name $root "user"] return [xml_node_get_attribute $user nsid] }

ad_proc flickr::people::getPublicPhotos { {-multirow images} user_id {per_page 5} {page 1} } { set doc [util_httpget [export_vars -base \ { { method flickr.people.getPublicPhotos } { api_key [flickr::api_key] } user_id per_page page }]] set xml [xml_parse -persist $doc] set root [xml_doc_get_first_node $xml] set photos [xml_node_get_first_child_by_name $root "photos"] template::multirow create $multirow url src width height title foreach photo [xml_node_get_children_by_name $photos "photo"] { foreach attr { id secret server title } { set $attr [xml_node_get_attribute $photo $attr] } template::multirow append $multirow \$user_id/$id \ http://photos${server}${id}_${secret}_s.jpg 75 75 $title } }
Feel free to use for any purpose. Beware that there are no safety guards. Use at your own risk :)


There are no comments yet. Be the first one to leave a comment!

Leave a comment