Saturday, January 17, 2009

Android Pt. 3: Photo uploading

I found enough bits and pieces of code to hobble together a photo uploader. This blog post was helpful:


http://itp.nyu.edu/~dbo3/blog/?p=122


Speaking of helpful, once running an Android app with the emulator, you might wonder where Log statements are going. Standard out doesn't show them in the Eclipse editor, but you can tail them with this command:


adb logcat *:W


Where do I want my uploaded photos to go? I have been thinking about writing a small appengine app which could be used for coordinating, managing, and searching for the photographs. Maybe I'll use flickr for photo storage, at least initially.

Next up I need to find the code to upload the photos to flicker. Knowing that I will need an API key, I requested and received one from Amazon. I had heard that that flickr uses a hybrid rest api, and sure enough, after searching around I found no pure REST interface for authenticating and uploading.

I've decided to test the basic uploading steps in Python first. Once I get it working, I'll go back and write the more verbose version using JAVA.

I found that the first step in uploading is going through an authentication handshaking sequence.
First up, grab a frob from flickr.


import md5
import xmlrpclib

uri = "http://api.flickr.com/services/xmlrpc/"
key = YOUR_FLICKR_API_KEY
secret = YOUR_FLICKR_SECRET
proxy = xmlrpclib.ServerProxy( uri )
secretstr = secret + "api_key" + key
hexsig = md5.new( sigstr ).hexdigest()
resturi = "http://api.flickr.com/services/rest/?method=flickr.auth.getFrob&api_key="+key+"&api_sig="+sig
result = proxy.flickr.auth.getFrob( {'api_key': key, 'api_sig': sig} )

print result



At this point, I must take a break and rejoin the human race. More on this next time.

No comments: