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"]
def iot_get_return(): url = "https://iot.wuliancloud.com:443/sso/login/byphone" # 测试的接口url # data = { # "phone": "18512530681", # "phoneCountryCode": 86, # "password": "******", # "terminalId": "a50b0fff867a8ab8f252bb65f321e6bb" # } data = { "phone": "18168020465", "phoneCountryCode": 86, "password": "******", "terminalId": "a50b0fff867a8ab8f252bb65f321e6bb" } # 接口数据 # data = { # "phone": "15951644332", # "phoneCountryCode": 86, # "password": "******", # "terminalId":"de3f365cf53a76f62b9624315349ab7a" # } # 接口数据 headers = sso_post_headers.post_generate_headers(data) r = requests.post(url=url, json=data, headers=headers) # 发送请求 get_return = json.loads(r.text) global_value.set_get_return_value(get_return) return get_return
def iot_get_return(): url = "https://iot.wuliancloud.com:443/sso/login/byphone" # 测试的接口url data = { "phone": "18168020465", "phoneCountryCode": 86, "password": "******", "terminalId": "a50b0fff867a8ab8f252bb65f321e6bb" } # 接口数据 headers = sso_post_headers.post_generate_headers(data) r = requests.post(url=url, json=data, headers=headers) # 发送请求 get_return = json.loads(r.text) global_value.set_get_return_value(get_return) return get_return
def test_get_token(): url = "https://iot.wuliancloud.com:443/sso/login/byphone" # 测试的接口url data = { "phone": "13675124538", "phoneCountryCode": 86, "password": "******", "terminalId": "***" } # 接口数据 headers = sso_post_headers.post_generate_headers(data) r = requests.post(url=url, json=data, headers=headers) # 发送请求 #print(r.text) hjson = json.loads(r.text) token = hjson['data']['token'] #print (hjson) return token
def change_phone_number(self): url_token = "https://iot.wuliancloud.com:443/sso/login/byphone" # 测试的接口url data = { "phone": "18120135777", "phoneCountryCode": "86", "password": "******", "terminalId": "a50b0fff867a8ab8f252bb65f321e6bb" } # 接口数据 headers = post_generate_headers(data) r = requests.post(url=url_token, json=data, headers=headers) # 发送请求 hjson = json.loads(r.text) token = hjson['data']['token'] #print (token) url = "https://iot.wuliancloud.com:443/api/user/phone/update" # 测试的接口url partnerId = "wulian_app" partnerkey = "fb1bbde01c9a4d45d82d5f5107b1f4dd7c105af06c928ce14878cdda03874dcc" time_now = time.time() data_recover = { "phone": "13675124538", "phoneCountryCode": "86", "authCode": "123456" } # 接口数据 data_new = json.dumps(data_recover) data_list = [ partnerId, '&', data_new, '&', partnerkey, '&', str(time_now) ] data_str = ''.join(data_list) #print(data_str) sign_data = sha1.str_encrypt(data_str.encode("utf8")) sign_data = sign_data.lower() headers = {"Content-Type": "application/json", "WL-PARTNER-ID": "wulian_app", "WL-TIMESTAMP": str(time_now), \ "WL-SIGN": sign_data, "WL-TID": "a50b0fff867a8ab8f252bb65f321e6bb", "WL-TOKEN": token} #print (headers) r = requests.post(url=url, json=data_recover, headers=headers) # 发送请求 #print(r.text) return r # changephonenumber = Change_phone_number() # changephonenumber.change_phone_number()
def change_phone_password(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) # 发送请求 hjson = json.loads(r.text) token = hjson['data']['token'] url = "https://iot.wuliancloud.com:443/api/user/updatepass" # 测试的接口url partnerId = "wulian_app" partnerkey = "fb1bbde01c9a4d45d82d5f5107b1f4dd7c105af06c928ce14878cdda03874dcc" time_now = time.time() data_recover = { "password": "******", "newpassword": "******" } # 接口数据 data_new = json.dumps(data_recover) data_list = [ partnerId, '&', data_new, '&', partnerkey, '&', str(time_now) ] data_str = ''.join(data_list) #print(data_str) sign_data = sha1.str_encrypt(data_str.encode("utf8")) sign_data = sign_data.lower() headers = {"Content-Type": "application/json", "WL-PARTNER-ID": "wulian_app", "WL-TIMESTAMP": str(time_now), \ "WL-SIGN": sign_data, "WL-TID": "a50b0fff867a8ab8f252bb65f321e6bb", "WL-TOKEN": token} #print (headers) r = requests.post(url=url, json=data_recover, headers=headers) # 发送请求 print(r.text) return r # c=Change_phone_password() # c.change_phone_password()
def iot_get_AESkey(): url = "https://testv2.wulian.cc:50090/sso/login/byphone" # 测试的接口url data = { "phone": "13675124538", "phoneCountryCode": 86, "password": "******", "terminalId": "***" } # 接口数据 headers = sso_post_headers.post_generate_headers(data) r = requests.post(url=url, json=data, headers=headers) # 发送请求 #print(r.text) hjson = json.loads(r.text) AESkey = hjson['data']['secretKey'] # print (AESkey) # print(type(AESkey)) return AESkey # iot_get_AESkey()
def reg_bythird(self): url = "https://testv2.wulian.cc:50090/sso/reg/bythird" for i in range(3): i = i + 1 j = 0 if i == 1: data = { "thirdType": i, "openId": "ovQgr0upGkMQ1ztcFivYTpwBY3LA", "terminalId": "f4cede55dfdcf29ab56c2adbf0ee4145", "avatar": "http:\/\/wx.qlogo.cn\/mmopen\/5RCxkL3Un85WDJ6KIez7arY9QyayoFEhkEBXzZia2EZwJlUgaWp\ J44FhVhtkQUyFmcicooiaLrUwIzkuxicfhWTtlMvZMBn5tCsv\/0", "nick": "人来人往", "phone": "13776627090", "phoneCountryCode": "86", "email": "***", "password": "******" } # 接口数据 headers = post_generate_headers(data) #print(headers) r = requests.post(url=url, json=data, headers=headers) # 发送请求 #print(r.text) postanswer = json.loads(r.text, encoding='utf-8') #print(postanswer) j = j + int(postanswer["resultCode"]) #print(j) #####缺少删除账号的接口,导致只能注册一个账号 elif i == 2: data = { "thirdType": i, "terminalId": "f4cede55dfdcf29ab56c2adbf0ee4145", "openId": "8005329582F41D11944FA953FB526A13", "avatar": "http:\/\/q.qlogo.cn\/qqapp\/1106062262\/8005329582F41D11944FA953FB526A13\/100", "nick": "人来人往", "phone": "13776627095", "phoneCountryCode": "86", "email": "***", "password": "******" } # 接口数据 headers = post_generate_headers(data) r = requests.post(url=url, json=data, headers=headers) # 发送请求 postanswer = json.loads(r.text, encoding='utf-8') j = j + int(postanswer["resultCode"]) elif i == 3: data = { "thirdType": i, "openId": "1820499241", "avatar": "http:\/\/tvax2.sinaimg.cn\/crop.0.25.1242.1242.50\/6c829d29ly8ff1olwh2lhj20yi0zxwo3.jpg", "nick": "Flush0702", "phone": "13776627095", "phoneCountryCode": "86", "email": "***", "password": "******" } # 接口数据 headers = post_generate_headers(data) r = requests.post(url=url, json=data, headers=headers) # 发送请求 postanswer = json.loads(r.text, encoding='utf-8') j = j + int(postanswer["resultCode"]) print(str(j)) return str(j)