帮我登录api poloniex。下面是我尝试登录的代码,但它给了我一个错误!Python 3.5 版。帮助我,请理解我做错了什么!
import urllib
import requests
import json
import time
import hmac,hashlib
api_secret ="111111111111111111111111111111111111111111111111111111111"
api_key="YYYYYYYY-IIIIIIII-PPPPPPPP-LLLLLLLL"
nonce = int(time.time() * 1000)
parms = {"nonce": nonce,"command":'returnBalances'}
post_data = urllib.parse.urlencode(parms)
sign = hmac.new( api_secret.encode(),post_data.encode(), hashlib.sha512).hexdigest()
print(sign)
headers = {"Sign":sign,"Key":api_key}
public = requests.post('https://poloniex.com/tradingApi',post_data,headers)
print(public.text)
程序的结果如下: {"error":"Invalid API key/secret pair."}