注意:我解决了我的问题。但是,它进行了一些增量更改。如果您遇到此页面,请随时查看我的 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))))