【问题标题】:Empty response from Bitstamp.net来自 Bitstamp.net 的空响应
【发布时间】:2017-09-08 17:55:18
【问题描述】:

我正在尝试使用来自 Bitstamp 的私有 api 来查询我的帐户余额。我相信我发布了正确的数据,因为没有返回错误,但 Bitstamp 的答案总是空的

*   Trying 107.154.249.133...
* Connected to www.bitstamp.net (107.154.249.133) port 443 (#0)
* ALPN, offering http/1.1
* Cipher selection:         
ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
* successfully set certificate verify locations:
*   CAfile: /etc/ssl/certs/ca-certificates.crt
  CApath: /etc/ssl/certs
* NPN, negotiated HTTP1.1
* SSL connection using TLSv1.2 / ECDHE-RSA-AES256-GCM-SHA384
* ALPN, server did not agree to a protocol
* Server certificate:
*    subject: OU=Domain Control Validated; CN=*.bitstamp.net
*    start date: Apr  8 14:11:39 2015 GMT
*    expire date: Apr  8 15:48:13 2018 GMT
*    subjectAltName: www.bitstamp.net matched
*    issuer: C=US; ST=Arizona; L=Scottsdale; O=GoDaddy.com, Inc.;     
OU=http://certs.godaddy.com/repository/; CN=Go Daddy Secure Certificate     
Authority - G2
*    SSL certificate verify ok.
> POST /api/v2/balance HTTP/1.1
Host: www.bitstamp.net
User-Agent: Bitstamp C++ API Client
Accept: */*
Content-Length: 134
Content-Type: application/x-www-form-urlencoded

* upload completely sent off: 134 out of 134 bytes
< HTTP/1.1 301 MOVED PERMANENTLY
< Access-Control-Allow-Headers: x-requested-with, Content-Type, origin, accept, cache-control
< Access-Control-Allow-Methods: POST, GET
< Access-Control-Allow-Origin: *
< Content-Language: en
< Content-Type: text/html; charset=utf-8
< Date: Fri, 08 Sep 2017 17:46:41 GMT
< Location: http://www.bitstamp.net/api/v2/balance/
< Server: Apache
< Strict-Transport-Security: max-age=63072000; includeSubDomains
< Vary: Accept-Language
< X-Frame-Options: SAMEORIGIN
< Content-Length: 0
< Connection: keep-alive
< Set-Cookie: visid_incap_99025=wHhR5uPzT92ReB9XbeNToIHXslkAAAAAQUIPAAAAAAAbNQJEog5ZojcqdOv0dFhd; expires=Sat, 08 Sep 2018 10:32:13 GMT; path=/; Domain=.bitstamp.net
< Set-Cookie: nlbi_99025=VyBXXwUOsQHckThX8F1n9AAAAABOW3tLZ0nUHyp47yinIimv; path=/; Domain=.bitstamp.net
< Set-Cookie: incap_ses_569_99025=04PeXe3KGFAAVw//8n7lB4HXslkAAAAA09BkGnsaiskl2dkFxzhFXQ==; path=/; Domain=.bitstamp.net
< X-Iinfo: 9-15073063-15060114 PNNN RT(1504892800858 31) q(0 0 0 -1) r(2 2)     U6
< X-CDN: Incapsula
< 
* Connection #0 to host www.bitstamp.net left intact
result: 0
response: 
terminate called after throwing an instance of 'std::runtime_error'
  what():  Bitstamp response doesn't contain result data

有什么想法吗? 提前非常感谢!

【问题讨论】:

  • 您使用哪个工具发送 API 请求?在 HTTP 请求中,API 密钥、签名和 nonce 在哪里?
  • 我在 C++ 中使用 curl 来发送我的请求。正如 Bitstamp (bitstamp.net/api) 所解释的:所有私有 API 调用都需要身份验证。要成功进行身份验证,您需要提供 API 密钥、签名和 nonce 参数,签名是包含 nonce、客户 ID 和 API 密钥的 HMAC-SHA256 编码消息。
  • 能否提供curl命令(当然可以隐藏敏感信息)?
  • 我遇到了同样的问题,但在节点中。很确定我正在正确地创建签名。我已经使用 json 和 formData 发布过,但两者都得到了 301。如果 op 发现这一点,我们将不胜感激。

标签: rest api http


【解决方案1】:

最初我的余额路径是 /balance,但在更改为 /balance/ 后它工作并得到了 200 的有效载荷。

所以不要使用http://www.bitstamp.net/api/v2/balance,而是使用http://www.bitstamp.net/api/v2/balance/,注意尾部的反斜杠

【讨论】:

  • 确实如此!不知道为什么我没有首先测试这个......
猜你喜欢
  • 2023-03-25
  • 2014-03-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-03-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多