diff --git a/api_class/__init__.py b/api_class/__init__.py index d3d96ca..0fe2c0c 100644 --- a/api_class/__init__.py +++ b/api_class/__init__.py @@ -1,22 +1,16 @@ -# -*- coding: utf-8 -*- import json import urllib -import urllib2 +import requests class Api(object): - def __init__(self, srv_address='http://195.64.222.86:8087'): + def __init__(self, srv_address='http://***:8082'): self.srv_address = srv_address def call_api(self, model, params): - encoded_params = urllib.urlencode(params) api_url = "{0}/rest_api/v2/{1}/".format(self.srv_address, model) - print(api_url) - print('pamams: {0}'.format(encoded_params)) - req = urllib2.Request(api_url, encoded_params) - response = urllib2.urlopen(req) - result = response.read() - obj= json.loads(result) + req = requests.post(url=api_url, data=params) + obj= req.json() if obj.get('error'): print(u'Произошла ошибка на стороне биллинга:{0}'.format(obj['error'])) - return obj \ No newline at end of file + return obj