X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/5913c54d19b8f6775633176032161d49f9b2f1aa..81f5e7445d649ead05b4d3d0a15b742444cd8b06:/src/apiclient/__init__.py?ds=sidebyside diff --git a/src/apiclient/__init__.py b/src/apiclient/__init__.py index 56ecb96d..36cd7ec7 100644 --- a/src/apiclient/__init__.py +++ b/src/apiclient/__init__.py @@ -1,8 +1,9 @@ -import urllib - +# This file is part of FNP-Redakcja, licensed under GNU Affero GPLv3 or later. +# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. +# import json +from urllib.parse import urlencode import oauth2 - from apiclient.settings import WL_CONSUMER_KEY, WL_CONSUMER_SECRET, WL_API_URL, BETA_API_URL @@ -30,14 +31,14 @@ def api_call(user, path, data=None, beta=False): client = oauth2.Client(wl_consumer, token) if data is not None: data = json.dumps(data) - data = urllib.urlencode({"data": data}) + data = urlencode({"data": data}) resp, content = client.request( - "%s%s" % (api_url, path), - method="POST", - body=data) + "%s%s" % (api_url, path), + method="POST", + body=data) else: resp, content = client.request( - "%s%s" % (api_url, path)) + "%s%s" % (api_url, path)) status = resp['status'] if status == '200': @@ -48,4 +49,3 @@ def api_call(user, path, data=None, beta=False): raise ApiError('User not authorized for publishing.') else: raise ApiError("WL API call error %s, path: %s" % (status, path)) -