def post_code_list(code_key): """ 提交助力码 :return: """ code_list = [] item_list = Code.get_codes(code_key) for item in item_list: code_list.append({ 'account': item.account, 'code_key': item.code_key, 'code_val': item.code_val, }) if len(code_list) < 1: return url = 'https://jd-share-code.vercel.app/api/' params = {'items': code_list, 'os': os.getenv('HOSTNAME', '')} params['sign'] = sign(params) try: response = requests.post(url, json=params, verify=False, timeout=10) if response.json().get('code') == 0: println('成功提交助力码!') else: println('提交助力码失败!') except Exception as e: println('提交助力码失败, {}'.format(e.args))
def post_code_list(code_key): """ 提交助力码 :return: """ code_list = [] item_list = Code.get_codes(code_key) for item in item_list: code_list.append({ 'account': item.account, 'code_key': item.code_key, 'code_val': item.code_val, }) if len(code_list) < 1: return url = 'http://service-ex55qwbk-1258942535.gz.apigw.tencentcs.com/release/' params = { 'items': code_list, 'os': os.getenv('HOSTNAME', '') } params['sign'] = sign(params) try: headers = { 'user-agent': USER_AGENT, 'Content-Type': 'application/json' } response = requests.post(url, json=params, verify=False, timeout=20, headers=headers) if response.json().get('code') == 0: println('成功提交助力码!') else: println('提交助力码失败!') except Exception as e: println('提交助力码失败, {}'.format(e.args))