Skip to content

Instantly share code, notes, and snippets.

@Ceasar
Created October 29, 2011 06:10
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 Ceasar/1324162 to your computer and use it in GitHub Desktop.
Save Ceasar/1324162 to your computer and use it in GitHub Desktop.
A module for accessing APIs.
import urllib
import urllib2
import json
from ..settings import API, TOKEN
def pcr(*args, **kwargs):
kwargs["token"] = TOKEN
path = "".join((API, "/".join([str(arg) for arg in args]), "?", urllib.urlencode(kwargs)))
page = urllib2.build_opener().open(path)
return json.loads(page.read())['result']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment