【发布时间】:2021-12-06 05:58:13
【问题描述】:
我尝试用环形语言翻译这个 curl 字符串(它有效,我测试过)
curl -H "X-MBX-APIKEY: ----MY API KEY HERE----" -X POST 'https://api.binance.com/api/v3/order' -d 'symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000&timestamp=1499827319559&signature=c8db56825ae71d6d79447849e617115f4a920fa2acdcab2b053c4b2838bd6b71'
但脚本总是返回我 {"code":-2014,"msg":"API-key format invalid."}
Load "libcurl.ring"
Load "guilib.ring"
load "stdlib.ring"
my_api_key = "---API KEY HERE ---"
my_part = "symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559&signature=c8db56825ae71d6d79447849e617115f4a920fa2acdcab2b053c4b2838bd6b71"
my_URL= "https://api.binance.com/api/v3/order"
userAgent = "Mozilla/5.0 (Windows NT 5.1; rv:31.0) Gecko/20100101 Firefox/31.0"
curl = curl_easy_init()
curl_easy_setopt(curl, CURLOPT_POST, 1)
curl_easy_setopt(curl, CURLOPT_USERAGENT, userAgent)
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, FALSE)
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 2)
# Header
mylist = curl_slist_append(null,'accept-encoding: *')
mylist = curl_slist_append(mylist,'authorization: X-MBX-APIKEY: ' + my_api_key )
mylist = curl_slist_append(mylist,'connection: close')
mylist = curl_slist_append(mylist,'content-length: ' + len(my_part) )
mylist = curl_slist_append(mylist,'content-type: application/json')
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, mylist)
# Website
curl_easy_setopt(curl, CURLOPT_URL, my_URL)
# Body
curl_easy_setopt(curl, CURLOPT_POSTFIELDS,my_part )
cOutput = curl_easy_perform(curl) ```
thanks at all
【问题讨论】: