Create a gist now

Instantly share code, notes, and snippets.

Ship Library Python Example
import json
import urllib
import urllib2
# Set up recipients array with two recipients
recipients = [
{
'name': 'John Smith',
'street1': '1 Main St',
'street2': 'Apt 208',
'city': 'San Francisco',
'state': 'CA',
'postalcode': '94102',
'country': 'United States'
},
{
'name': 'Jane Doe',
'street1': '123 Mission Street',
'city': 'San Francisco',
'state': 'CA',
'postalcode': '94105',
'country': 'United States',
}
]
# Set up sender array
sender = {
'name': 'Pepper Gram',
'email': 'pepper@sincerely.com',
'street1': '800 Market Street',
'city': 'San Francisco',
'state': 'CA',
'postalcode': '94102',
'country': 'United States',
}
params = {
'appkey': 'YOUR_APPKEY_HERE',
'testMode': True,
'frontPhotoId': 123456,
'recipients': json.dumps(recipients),
'sender': json.dumps(sender),
}
data = urllib.urlencode(params)
req = urllib2.Request('https://snapi.sincerely.com/shiplib/create', data, {})
r = urllib2.urlopen(req)
resp = json.loads(r.read())
r.close()
if resp.get('success'):
# Success!
print resp
else:
print 'An error occurred.'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment