Guest User

Untitled

a guest
Dec 15th, 2018
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.47 KB | None | 0 0
  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))
Add Comment
Please, Sign In to add comment