我知道我问这个问题听起来像是在冒险。不过,我已经连续几个小时不停地撞着它了。我试图从BTC-e
得到响应,我有一个工作的python2版本,它在python3中失败了。我试着自动转换它,查找包名的变化等等,结果就死在我身上了。这是一个正在工作的python2示例:(不是我的代码)
#! /usr/bin/python
import httplib
import urllib
import json
import hashlib
import hmac
from auth import Ekey, Esecret
# Replace these with your own API key data
BTC_api_key = Ekey
BTC_api_secret = Esecret
# Come up with your own method for choosing an incrementing nonce
def generate_nonce(length=8):
"""Generate pseudorandom number."""
return ''.join([str(random.randint(0, 9)) for i in range(length)])
nonce = generate_nonce()
# method name and nonce go into the POST parameters
params = {"method":"getInfo",
"nonce": nonce}
params = urllib.urlencode(params)
# Hash the params string to produce the Sign header value
H = hmac.new(BTC_api_secret, digestmod=hashlib.sha512)
H.update(params)
sign = H.hexdigest()
headers = {"Content-type": "application/x-www-form-urlencoded",
"Key":BTC_api_key,
"Sign":sign}
conn = httplib.HTTPSConnection("btc-e.com")
conn.request("POST", "/tapi", params, headers)
response = conn.getresponse()
print response.status, response.reason
print json.load(response)
conn.close()
然后,我从某个返回无效签名的不幸的堆栈溢出混合物。在
^{pr2}$它们有什么不同?对于api文档,我尝试将其与go here一起使用。在
你的屁股太大了。从您链接到的网站的API docs中:
当前的时间戳是149577892473,远大于4294967294。在
相关问题 更多 >
编程相关推荐