Ejemplo n.º 1
0
 def iot_delete_answer(self):
     get_return = iot_get_return()
     csv_dict = Read_csv().read_csv()
     secretKey = get_return["data"]['secretKey']  # 每个接口必须要传AESkey
     secretuId = get_return["data"]['uId']  # 每个接口必须要传uId
     # 获取到的字符串格式数据转换成dict格式
     interface = json.loads(csv_dict[self.key], encoding='utf-8')
     # 读取url的value
     url = get_serveraddress.get_serveraddress(
     )[adressIndex] + interface["url"]
     # 判断uId 和token 字符串
     if "uId" in url:
         url = url.replace("uId", get_return["data"]['uId'])
     # 读取url的data
     data = interface["data"]
     if "token" in data:
         data["token"] = get_return["data"]['token']
     req_url = url + '?' + parse.urlencode(data)  # 构建get请求
     r = requests.delete(url=req_url)  # 发送请求
     getanswer = json.loads(r.text, encoding='utf-8')
     msgContent = getanswer['msgContent']
     # 解密msgContent
     msgContent_base64 = Base64(msgContent)
     msgContent_base64 = msgContent_base64.b64decode()
     return_data = Iot_encry_decry(msgContent_base64, secretKey, secretuId)
     return_data = return_data.decry()
     return return_data
 def user_wechat_update_recover(self):
     url_token = "https://iot.wuliancloud.com:443/sso/login/byphone"  # 测试的接口url
     data = {
         "phone": "18168020465",
         "phoneCountryCode": "86",
         "password": "******",
         "terminalId": "a50b0fff867a8ab8f252bb65f321e6bb"
     }  # 接口数据
     headers = post_generate_headers(data)
     r = requests.post(url=url_token, json=data, headers=headers)  # 发送请求
     get_return = json.loads(r.text)
     global_value.set_get_return_value(get_return)
     csv_dict = Read_csv().read_csv()
     # 获取到的字符串格式数据转换成dict格式
     interface = json.loads(csv_dict["user/wechat/update_recover"],
                            encoding='utf-8')
     # 读取url的value
     url = get_serveraddress.get_serveraddress()[0] + interface["url"]
     # 读取url的data
     data = interface["data"]
     # 判断uId 和token 字符串
     if "uId" in data:
         data["uId"] = get_return["data"]['uId']
     # 读取url的data
     if "token" in data:
         data["token"] = get_return["data"]['token']
     get_headers = Post_headers(data)
     headers = get_headers.api_post_generate_headers(
         get_return["data"]['token'])
     r = requests.post(url=url, json=data, headers=headers)  # 发送请求
     postanswer = json.loads(r.text, encoding='utf-8')
     return postanswer["resultCode"]
Ejemplo n.º 3
0
 def api_get_answer(self):
     get_return = iot_get_return()
     print(get_return)
     csv_dict = Read_csv().read_csv()
     # 获取到的字符串格式数据转换成dict格式
     interface = json.loads(csv_dict[self.key], encoding='utf-8')
     # 读取url的value
     url = get_serveraddress.get_serveraddress(
     )[adressIndex] + interface["url"]
     # 读取url的data
     data = interface["data"]
     # 判断uId 和token 字符串
     if "uId" in data:
         data["uId"] = get_return["data"]['uId']
     # 读取url的data
     if "token" in data:
         data["token"] = get_return["data"]['token']
     get_headers = Get_headers(data)
     headers = get_headers.api_get_generate_headers(
         get_return["data"]['token'])
     req_url = url + '?' + parse.urlencode(data)  # 构建get请求
     req_url = parse.unquote(req_url)  # 解码  处理特殊字符
     r = requests.get(url=req_url, headers=headers)  # 发送请求
     getanswer = json.loads(r.text, encoding='utf-8')
     print(getanswer)
     return getanswer
Ejemplo n.º 4
0
 def api_post_answer(self):
     get_return = iot_get_return()
     print(get_return)
     csv_dict = Read_csv().read_csv()
     # 获取到的字符串格式数据转换成dict格式
     interface = json.loads(csv_dict[self.key], encoding='utf-8')
     # 读取url的value
     url = get_serveraddress.get_serveraddress(
     )[adressIndex] + interface["url"]
     # 读取url的data
     data = interface["data"]
     # 判断uId 和token 字符串
     if "uId" in data:
         data["uId"] = get_return["data"]['uId']
     # 读取url的data
     if "token" in data:
         data["token"] = get_return["data"]['token']
     # if "unionId" in data:
     #     if data["unionId"]=="ovQgr0rNtJ03yV3bN9xlTjzQUM0":
     #         data["unionId"]="ovQgr0rNtJ03yV3bN9xlTjz"+publicMethod.randomMethod()
     get_headers = Post_headers(data)
     headers = get_headers.api_post_generate_headers(
         get_return["data"]['token'])
     r = requests.post(url=url, json=data, headers=headers)  # 发送请求
     postanswer = json.loads(r.text, encoding='utf-8')
     return postanswer
Ejemplo n.º 5
0
 def sso_post_answer(self):
     csv_dict = Read_csv().read_csv()
     # 获取到的字符串格式数据转换成dict格式
     interface = json.loads(csv_dict[self.key], encoding='utf-8')
     # 读取url的value
     url = get_serveraddress.get_serveraddress(
     )[adressIndex] + interface["url"]
     # 读取url的data
     data = interface["data"]
     if global_value.get_execute_value() == "1":
         get_return = global_value.get_get_return_value()
         # 更改参数的data
         if "token" in data:
             data["token"] = get_return["data"]['token']
     get_headers = Post_headers(data)
     headers = get_headers.sso_post_generate_headers()
     r = requests.post(url=url, json=data, headers=headers)  # 发送请求
     print(r)
     postanswer = json.loads(r.text, encoding='utf-8')
     return postanswer
Ejemplo n.º 6
0
 def sso_get_answer(self):
     csv_dict = Read_csv().read_csv()
     # 获取到的字符串格式数据转换成dict格式
     interface = json.loads(csv_dict[self.key], encoding='utf-8')
     # 读取url的value
     url = get_serveraddress.get_serveraddress(
     )[adressIndex] + interface["url"]
     # 读取url的data
     data = interface["data"]
     if global_value.get_execute_value() == "1":
         get_return = iot_get_return()
         # 更改参数的data
         if "token" in data:
             data["token"] = get_return["data"]['token']
     get_headers = Get_headers(data)
     headers = get_headers.sso_get_generate_headers()
     req_url = url + '?' + parse.urlencode(data)  # 构建get请求
     r = requests.get(url=req_url, headers=headers)  # 发送请求
     getanswer = json.loads(r.text, encoding='utf-8')
     return getanswer
Ejemplo n.º 7
0
 def iot_icampost_answer(self):
     get_return = iot_get_return()
     csv_dict = Read_csv().read_csv()
     # 获取到的字符串格式数据转换成dict格式
     interface = json.loads(csv_dict[self.key], encoding='utf-8')
     # 读取url的value
     url = get_serveraddress.get_serveraddress(
     )[adressIndex] + interface["url"]
     # 判断uId 和token 字符串
     if "uId" in url:
         url = url.replace("uId", get_return["data"]['uId'])
     # 读取url的data
     data = interface["data"]
     if "token" in data:
         data["token"] = get_return["data"]['token']
     get_headers = Post_headers(data)
     headers = get_headers.api_icampost_generate_headers()
     r = requests.post(url=url, json=data, headers=headers)  # 发送请求
     postanswer = json.loads(r.text, encoding='utf-8')
     return postanswer
Ejemplo n.º 8
0
 def iot_post_answer(self):
     get_return = iot_get_return()
     csv_dict = Read_csv().read_csv()
     secretKey = get_return["data"]['secretKey']  # 每个接口必须要传AESkey
     secretuId = get_return["data"]['uId']  # 每个接口必须要传uId
     # 获取到的字符串格式数据转换成dict格式
     interface = json.loads(csv_dict[self.key], encoding='utf-8')
     # 读取url的value
     url = get_serveraddress.get_serveraddress(
     )[adressIndex] + interface["url"]
     # 判断uId 和token 字符串
     if "uId" in url:
         url = url.replace("uId", get_return["data"]['uId'])
     # 读取url的data
     data = interface["data"]
     if "token" in data:
         data["token"] = get_return["data"]['token']
     generate_nonce = iot_generate_nonce()  # 产生随机数
     timestamp = time.time()
     timestamp = str(int(round(timestamp * 1000)))
     data = json.dumps(data)  # 字符串数据
     iot_aes = Iot_aes(data, secretKey, generate_nonce, timestamp,
                       secretuId)
     msgContent = iot_aes.get_msgContent()
     signature = iot_aes.get_signature()
     message = {
         "signature": signature,
         "nonce": generate_nonce,
         "timestamp": timestamp,
         "msgContent": msgContent
     }
     r = requests.post(url=url, json=message)  # 发送请求
     postanswer = json.loads(r.text, encoding='utf-8')
     print(postanswer)
     msgContent = postanswer['msgContent']
     # 解密msgContent
     msgContent_base64 = Base64(msgContent)
     msgContent_base64 = msgContent_base64.b64decode()
     return_data = Iot_encry_decry(msgContent_base64, secretKey, secretuId)
     return_data = return_data.decry()
     return return_data
Ejemplo n.º 9
0
 def iot_icamget_answer(self):
     get_return = iot_get_return()
     csv_dict = Read_csv().read_csv()
     secretKey = get_return["data"]['secretKey']  # 每个接口必须要传AESkey
     secretuId = get_return["data"]['uId']  # 每个接口必须要传uId
     # 获取到的字符串格式数据转换成dict格式
     interface = json.loads(csv_dict[self.key], encoding='utf-8')
     # 读取url的value
     url = get_serveraddress.get_serveraddress(
     )[adressIndex] + interface["url"]
     # 判断uId 和token 字符串
     if "uId" in url:
         url = url.replace("uId", get_return["data"]['uId'])
     # 读取url的data
     data = interface["data"]
     if "token" in data:
         data["token"] = get_return["data"]['token']
     req_url = url + '?' + parse.urlencode(data)  # 构建get请求
     r = requests.get(url=req_url)  # 发送请求
     getanswer = json.loads(r.text, encoding='utf-8')
     return getanswer