4

注意:我解决了我的问题。但是,它进行了一些增量更改。如果您遇到此页面,请随时查看我的 github,看看我是如何使这个应用程序工作的。


我正在使用 http-kit 向 btc-china 发布请求。我想使用他们的交易API。我可以用 python 很好地做到这一点,但由于某种原因,我一直使用 clojure 和 http-kit 得到 401。我在下面发布了一段代码,这可能表明我没有正确使用 http-kit。除此之外,如果您想查看,这里是我的完整代码的 github:https ://github.com/gilmaso/btc-trading 以下是 btc-china api 文档:http ://btcchina.org /api-trade-documentation-en

(def options {:timeout 2000 ; ms
          :query-params (sorted-map :tonce tonce
                                    :accesskey access-key
                                    :requestmethod request-method
                                    :id tonce
                                    :method method
                                    :params "")
          :headers {"Authorization" auth-string
                    "Json-Rpc-Tonce" tonce}})

(client/post (str "https://" base-url) options
      (fn [{:keys [status headers body error]}] ;; asynchronous handle response
        (if error
          (println "Failed, exception is " error)
          (println "Async HTTP GET: " status))))
4

2 回答 2

4

引用bttchina 网站上的示例

# The order of params is critical for calculating a correct hash

clojure 哈希映射是无序的,如果顺序很重要,您不能使用 clojure 哈希映射文字来提供输入

于 2013-12-09T06:10:40.893 回答
1

我对 bitstamp api 有非常相似的问题。解决方案是替换:query-params:form-params. 然后参数在正文中发送。我注意到在您的 api 中,您是在正文中手动发送的。看起来 using:form-params也可能对您的情况有所帮助。

于 2014-01-16T06:22:09.867 回答