import json import time import random import string import hashlib import requests from aes import MyHash partnerId = '108463' partnerKey = 'tdz5xjtmuymkrhbx460iwv8kyw9hasqa' nonce = ''.join(random.sample(string.ascii_letters+string.digits,32)) #nonce = 'WUKRmNYGcFaqgy7Hl8dbLOMzrSQuPfZ1' #print(nonce) cardSecret = ''.join(random.sample(string.ascii_letters+string.digits,32)) #cardSecret = 'GLDSZQ42eX8MB3V1fNsucghj9U5JrRlD' #key = ''.join(random.sample(string.ascii_letters+string.digits,16)) #print(key) #key = 'DXH5ozwbLtPuFhnJMdyijSI824k0ExWR' key = '9lI82q3eBZhdwk7b' helo = MyHash() cardSecret = helo.My_Aes_Encrypt(key,cardSecret) #cardSecret = 'VxuJa8EW4zKfykwt92ZFqToeiLG3gsCY' facePrice = 30 callbackUrl = 'http://127.0.0.1:9888' timestamp = int(time.time()) pre_sign = '{}{}{}{}{}{}{}'.format(partnerId,nonce,cardSecret,facePrice,callbackUrl,timestamp,partnerKey) #print(pre_sign) sign = hashlib.md5(pre_sign.encode(encoding='UTF-8')).hexdigest() #print(sign) data = { 'partnerId': partnerId, 'nonce': nonce, 'cardSecret': cardSecret, 'facePrice':facePrice, 'callbackUrl':callbackUrl, 'timestamp':timestamp, 'sign':sign } data_json = json.dumps(data) http_header = { 'Content-Type': 'application/json', 'Connection': 'close' } s = requests.session() s.keep_alive = False r_json = requests.post("http://47.108.14.99:8086/unicom/card/secret/push.json", data=data_json, headers=http_header) #r_json = requests.post("http://localhost:8086/unicom/card/secret/push.json", data=data_json, headers=http_header) #r_json = requests.post("http://47.108.14.99:8085/sup/order/add", data=data_json, headers=http_header) print( r_json.text )