Based on reading the Python FlickrAPI, I wrote a simple example using the flickrapi library:
import flickrapi
API_KEY = '[API_KEY]'
API_SECRET = '[API_SECRET]'
if __name__ == '__main__':
# instantiate the flickr object with the API_KEY, SECRET to return ElementTree entities
flickr = flickrapi.FlickrAPI(api_key=API_KEY,secret=API_SECRET,format='etree')
photos = flickr.photos_search(user_id='73509078@N00', per_page='10')
if photos.attrib['stat']:
for photo in photos.find('photos').getiterator('photo'):
id = photo.attrib['id']
secret = photo.attrib['secret']
server_id = photo.attrib['server']
farm_id = photo.attrib['farm']
user_id = photo.attrib['owner']
# calculate the thumbnail URL and photo URL
# http://www.flickr.com/services/api/misc.urls.html
thumbnail_url = "http://farm%s.static.flickr.com/%s/%s_%s_t.jpg" \
% (farm_id, server_id, id, secret)
photo_url = "http://www.flickr.com/photos/%s/%s" % (user_id, id)
print thumbnail_url, photo_url
Post a Comment