Created
February 4, 2011 20:39
-
-
Save berg/811726 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import urllib2 | |
import json | |
import pprint | |
from poster.encode import multipart_encode | |
from poster.streaminghttp import register_openers | |
register_openers() | |
token = '1|oauth_secret=...' | |
params = { | |
'oauth_token': token, | |
'caption': 'my cat with russian toy camera!', | |
'filter': 'xpro', | |
'share.twitter': 1, | |
'share.facebook': 0, | |
'geo.lat': 37.74086, | |
'geo.lon': -122.50009, | |
'file': file('cat.jpg', 'rb'), | |
} | |
datagen, headers = multipart_encode(params) | |
request = urllib2.Request('https://api-upload.picplz.com/api/v2/upload_basic.json', datagen, headers) | |
response_obj = json.load(urllib2.urlopen(request)) | |
pprint.pprint(response_obj) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment