Created
August 29, 2012 18:59
-
-
Save pythonjunkie/3517184 to your computer and use it in GitHub Desktop.
Validate in app purchases from App Store
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
import urllib, urllib2 | |
import simplejson as json | |
import datetime url = 'https://sandbox.itunes.apple.com/verifyReceipt' receipt_data = 'receipt_data' password = 'your_password' | |
data = { "receipt-data": receipt_data, "password": password } | |
headers = {'Content-Type': 'text/Json; charset=utf-8'} | |
dataj = json.dumps(data) | |
request = urllib2.Request(url, dataj, headers) | |
# In case you are wondering what is being sent and the format | |
print "request%s" % request.get_data() | |
# This shows the method either POST or GET (App store wants POST and not GET) | |
print "request type %s" % request.get_method() | |
start_time = datetime.datetime.now() | |
response = urllib2.urlopen(request) | |
wait_time = datetime.datetime.now() - start_time | |
print('Wait time for validation call: %s' % wait_time) | |
response_json = json.loads(response.read()) | |
print response_json |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment