Skip to content

Instantly share code, notes, and snippets.

@berg
Created February 4, 2011 20:39
Show Gist options
  • Save berg/811726 to your computer and use it in GitHub Desktop.
Save berg/811726 to your computer and use it in GitHub Desktop.
#!/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