Created
October 29, 2011 06:10
-
-
Save Ceasar/1324162 to your computer and use it in GitHub Desktop.
A module for accessing APIs.
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 | |
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