def _request(self, action='GET', url='/', data=None, query_params=None):
if data is None:
data = {}
if query_params is None:
query_params = {}
query_params['version'] = 1
query_params['type'] = 'xml'
query_params['key'] = self.options['auth_token']
r = requests.request(action, self.api_endpoint + url, params=query_params)
#data=json.dumps(data))
r.raise_for_status() # if the request fails for any reason, throw an error.
# TODO: check if the response is an error using
tree = ElementTree.ElementTree(ElementTree.fromstring(r.content))
root = tree.getroot()
if root.find('reply').find('code').text != '300':
raise Exception('An error occurred: {0}, {1}'.format(root.find('reply').find('detail').text, root.find('reply').find('code').text))
return root
评论列表
文章目录