def fsd_api_login(self, phone, flyuser_data): userdata = flyuser_data userdata['phone'] = phone flyuser_login_url = api.API_URL['fsdlogin'] print(userdata, '\n', flyuser_login_url) # 发送post请求 my_request = MyRequest(flyuser_login_url, userdata) reslist = my_request.request_token_fsd() res = reslist[0] token = reslist[1] userId = reslist[2] #print('token=',token) #print('userId=',userId) res = res.json() print("response: ", res) #解析response返回信息 err_flag, ret = my_request.decode_errorinfo_from_FSD(res) #print(ret) #返回值不报错时 if err_flag == True: print('FSD login successed') flag_fsd_login_status = 1 return flag_fsd_login_status, token, userId elif '密码不正确' in ret: print('FSD login error password', ret) flag_fsd_login_status = 2 return flag_fsd_login_status elif '账户已冻结' in ret: print('Freeze fly account can not login', ret) flag_fsd_login_status = 3 return flag_fsd_login_status else: print('Failed:FSD login failed') flag_fsd_login_status = 0 return flag_fsd_login_status
def fsd_api_register(self, phone): userdata = {} request_url = api.API_URL['fsdregister'] print('Test data and api url |', userdata, '| ', request_url) userdata['phone'] = phone # 发送post请求 my_request = MyRequest(request_url, userdata) reslist = my_request.request_token_fsd() res = reslist[0] token = reslist[1] userId = reslist[2] print('token=', token) print('userId=', userId) res = res.json() print("response: ", res) #解析response返回信息 err_flag, ret = my_request.decode_errorinfo_from_FSD(res) #print(ret) #返回值不报错时 if err_flag == True: print('FSD register successed') flag_status = 1 return flag_status, token, userId else: print('FSD register failed') flag_fsd_login_status = 0 return flag_fsd_login_status