Esempio n. 1
0
def send(data, method):
    url = "http://" + conf.host + "/openapi/gettasklist"

    auth = conf.gen_authorization(method, url)
    header = {
        'host': conf.host,
        'Content-Type': 'application/x-www-form-urlencoded',
        'authorization': auth,
        'accept': '*/*'
    }
    request = Request(url, data=data.encode("utf-8"), headers=header)
    response = None
    try:
        response = urlopen(request, timeout=60)
        post_res_str = response.read()
        d_json = json.loads(post_res_str)
        print(d_json, "##########")
        print(d_json['code'])
    except HTTPError as e:
        print("HTTPError")
        print(e.code, e.reason)
        print(e.read())
    except URLError as e:
        print("URLError")
        print(e)
Esempio n. 2
0
def send(data, method):
    url = "http://" + conf.host + "/openapi/createtask"

    auth = conf.gen_authorization(method, url)
    header = {
        'host': conf.host,
        'Content-Type': 'application/x-www-form-urlencoded',
        'authorization': auth,
        'accept': '*/*'
    }
    request = Request(url, data=data.encode(encoding='UTF8'), headers=header)
    response = None
    try:
        response = urlopen(request, timeout=60)
        post_res_str = response.read()
        print(post_res_str)
    except HTTPError as e:
        print("HTTPError")
        print(e.code, e.reason)
        print(e.read())
    except URLError as e:
        print("URLError")
        print(e)