SHARE
TWEET

Untitled

a guest Dec 15th, 2018 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class API:
  2.     def __init__(self, key):
  3.         self.header = dict(apikey=key)
  4.  
  5.     def call(self, method, params):
  6.         request = urllib2.Request(
  7.             self.url + method[0] + '/' + method[1],
  8.             urllib.urlencode(params),
  9.             self.header
  10.         )
  11.         try:
  12.             response = json.loads(urllib2.urlopen(request).read())
  13.             return response
  14.         except urllib2.HTTPError as error:
  15.             return dict(Error=str(error))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top