Created
January 11, 2012 17:53
-
-
Save xen/1595860 to your computer and use it in GitHub Desktop.
API call
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 urllib2, urllib | |
import hashlib | |
# http://pypi.python.org/pypi/simplejson/ | |
import simplejson | |
APIURL = 'http://api.aplatform.ru' | |
APPID = '' # Application id | |
SECRET = '' # Secret | |
def call(sid, **kw): | |
url_params = { | |
"secure": 1, | |
"app_id": APPID, | |
"sid": sid | |
} | |
url_params.update(kw) | |
params = "" | |
for key in sorted(url_params.keys()): | |
params += "%s=%s" %(key, url_params[key]) | |
params += SECRET | |
url_params['sig'] = hashlib.md5(params).hexdigest() | |
request = urllib2.urlopen(APIURL, urllib.urlencode(url_params)) | |
data = simplejson.load(req) | |
return data['data'] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment