我的爱好是通过 API 买卖比特币,并且我已经通过使用 lua 中也存在的“requests”库,使用 python 成功地做到了这一点。我正在使用 Bitstamp API。但是,我的 lua 代码无法正常工作。
这是可以运行的 python 代码
import time
import hashlib
import hmac
import requests
import ast
import pprint
nonce = str(int(time.time()))
customer_id = 'some id'
api_key = 'some string'
API_SECRET = 'some other string'
message = nonce + customer_id + api_key
signature = hmac.new(API_SECRET, msg=message, digestmod=hashlib.sha256).hexdigest().upper()
# --------------Requests Parameters------------------------
params = {"key": api_key, "signature": signature, 'nonce': nonce}
# --------------Get Account Balance--------------------------
r = requests.post('https://www.bitstamp.net/api/v2/balance/', data=params)
print(r.text)
Run Code Online (Sandbox Code Playgroud)
现在这段代码可以工作并且我得到了成功的响应。
然而,我的 lua 代码不起作用,因为我从 API 收到错误,所以这显然不是语法错误。这是lua代码。 …