我已经编写了这段python代码-
import json
import time
import hmac
import hashlib
import requests
secret = "somekey"
url = f"https://api.coindcx.com/exchange/v1/orders/status"
timeStamp = int(round(time.time() * 1000))
body = {
"id": "ead19992-43fd-11e8-b027-bb815bcb14ed",
"timestamp": timeStamp
}
json_body = json.dumps(body, separators=(',', ':'))
signature = hmac.new(secret.encode('utf-8'), json_body.encode('utf-8'), hashlib.sha256).hexdigest()
print(signature)
headers = {
'Content-Type': 'application/json',
'X-AUTH-APIKEY': "someapikey",
'X-AUTH-SIGNATURE': signature
}
response = requests.post(url, data=json_body, headers=headers)
print(response)
在围棋中我试着这样写-
type GetOrderStatusInput struct {
ID string `json:"id"`
Timestamp int64 `json:"timestamp"`
}
timestamp := time.Now().UnixNano() / 1000000
getOrderStatusInput := GetOrderStatusInput{
ID: "ead19992-43fd-11e8-b027-bb815bcb14ed",
Timestamp: timestamp,
}
但我不知道如何在这里进行json编码和hmac
相关问题 更多 >
编程相关推荐