Vizible’s Blog

Python – How to use Flickr API?

Posted in Python by wearetherock on July 11, 2009
# use http://stuvel.eu/flickrapi
# API key get from flickr web site

import flickrapi
class Uploader :
	def __init__(self, apiKey, secretKey) :
		self.flickr = flickrapi.FlickrAPI(apiKey, secretKey)
		(token, frob) = self.flickr.get_token_part_one(perms='write')
		if not token: raw_input("Press ENTER after you authorized this program")
		self.flickr.get_token_part_two((token, frob))

	def showProgress(self, progress, done) :
		if done :
			print 'Done uploading'
		else :
			print 'At %s%%' % progress

	def upload(self, image):
		self.flickr.upload(filename = image, callback = self.showProgress)

if __name__ == '__main__' :
	apiKey = 'xxxx'
	secretKey = 'xxxx'
	uploader = Uploader(apiKey, secretKey)
	image = 'into_the_wild.png'
	uploader.upload(image)
Advertisements
Tagged with: ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: