注:我解决了我的问题。然而,它采取了一些渐进的变化。如果你碰巧出现在这个页面上,可以在下面查看我的github,看看我是如何让这个应用程序工作的。
我正在使用http-kit向btc-中国发送请求。我想使用他们的交易api。我可以在python中很好地做到这一点,但出于某种原因,我一直使用clojure和http-kit获得401。下面我发布了一段代码,这可能表明我没有正确地使用http-kit。除此之外,这里还有我的完整代码的github,如果您想看一下:https://github.com/gilmaso/btc-trading,这里是btc-中国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))))发布于 2013-12-09 06:10:40
引用bttchina站点上的示例的话
# The order of params is critical for calculating a correct hashclojure散列映射是无序的,如果订单是重要的,则不能使用clojure散列映射文字提供输入。
发布于 2014-01-16 06:22:09
我在bitstamp api上也遇到了类似的问题。解决方案是将:query-params替换为:form-params。然后将参数发送到身体中。我注意到,在您的api中,您正在手动发送,然后在正文中发送。在您的情况下,使用:form-params似乎也会有所帮助。
https://stackoverflow.com/questions/20463919
复制相似问题