Skip to content

Commit

Permalink
add flickr example that demos listing my public photos
Browse files Browse the repository at this point in the history
  • Loading branch information
tswicegood committed Oct 28, 2009
1 parent 4528734 commit 2b5f0af
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions examples/flickr.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import os, sys
sys.path[0:0] = os.path.join(os.path.dirname(__file__), ".."),

from dolt import Dolt

class Flickr(Dolt):
def __init__(self, api_key, *args, **kwargs):
super(self.__class__, self).__init__(*args, **kwargs)
self._api_key = api_key
self._api_url = "http://api.flickr.com"
self._url_template = "%(domain)s/services/rest/?format=json&method=%(generated_url)s"
self._stack_collapser = self._collapse_stack
self._params_template = "&%s"

def _collapse_stack(self, *args, **kwargs):
self._attribute_stack[0:0] = "flickr",
return ".".join(self._attribute_stack)

def get_url(self):
url = super(self.__class__, self).get_url()
print url + "&api_key=%s" % self._api_key
return url + "&api_key=%s" % self._api_key

def _handle_response(self, response, data):
return super(self.__class__, self)._handle_response(response, data[14:-1])

if __name__ == "__main__":
api_key = raw_input("Flickr API key: ")
flickr = Flickr(api_key)
response = flickr.people.getPublicPhotos(user_id="18843927@N00")
for photo in response["photos"]["photo"]:
print "id [%s] title [%s]" % (photo['id'], photo['title'])

0 comments on commit 2b5f0af

Please sign in to comment.