Skip to content

Instantly share code, notes, and snippets.

@xen
Created January 11, 2012 17:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xen/1595860 to your computer and use it in GitHub Desktop.
Save xen/1595860 to your computer and use it in GitHub Desktop.
API call
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