python 3.6.1を使用してアカウントの残高を確認するためにfoxbit(blinktradeプラットフォーム)に接続しようとしました。私の端末でコードを実行して何も返しません。トレースバックなど何もありません。ちょうど空白。何か案は?前もって感謝します!BlinkTrade Rest API Returns Nothing(アカウント残高リクエスト)
import hashlib
import hmac
import time
import requests
import datetime
def send_msg(msg, env='prod'):
if env == 'prod':
BLINKTRADE_API_URL = 'https://api.blinktrade.com'
else:
BLINKTRADE_API_URL = 'https://api.testnet.blinktrade.com'
BLINKTRADE_API_VERSION = 'v1'
TIMEOUT_IN_SECONDS = 10
key = 'keykeykeykeykey32952592753'
secret = 'secretsecretsecret23535345'
secret2 = bytearray(secret, 'utf8') #turn secret into bytearray
dt = datetime.datetime.now()
nonce = str(int((time.mktime(dt.timetuple()) + dt.microsecond/1000000.0) * 1000000))
nonce = nonce.encode("utf8")
signature = hmac.new(secret2, nonce, digestmod=hashlib.sha256).hexdigest()
headers = {
'user-agent': 'blinktrade_tools/0.1',
'Content-Type': 'application/json', # You must POST a JSON message
'APIKey': key, # Your APIKey
'Nonce': nonce, # The nonce must be an integer, always greater than the previous one.
'Signature': signature # Use the API Secret to sign the nonce using HMAC_SHA256 algo
}
url = '%s/tapi/%s/message' % (BLINKTRADE_API_URL, BLINKTRADE_API_VERSION)
return requests.post(url, json=msg, verify=True, headers=headers).json()
# Request Balance
msg = {
"MsgType": "U2", # Balance Request
"BalanceReqID": 1 # An ID assigned by you. It can be any number. The response message associated with this request will contain the same ID.}
print(send_msg(msg))
あなたのソリューションをサポートするために、いくつかの詳細を追加してください。 –
このコードスニペットは問題を解決するかもしれませんが、[説明を含む](http://meta.stackexchange.com/questions/114762/explaining-entirely-code-based-answers)は本当にあなたの投稿の質を向上させるのに役立ちます。将来読者の質問に答えていることを覚えておいてください。そうした人々はあなたのコード提案の理由を知らないかもしれません。 – offbyone