我正在尝试编写一些代码来从ripple API (https://ripple.com/wiki/JSON_Messages)中检索我的帐户状态。我目前使用的代码如下:
#require "netclient";;
open Http_client.Convenience;;
let account_info =
[
("command","account_info");
("account","my_account_key")
]
;;
let response = http_post_message "http://s1.ripple.com:51234" account_info;;我正在向http://s1.ripple.com:51234发送请求,并且收到错误的请求错误。注意:我已经尝试了方法和命令作为参数,以及http_post和http_post_message方法。
# response#status;;
- : Http_client.status = `Client_error
# response#response_status;;
- : Nethttp.http_status = `Bad_request我肯定在请求数据的方式上做了一些根本错误的事情,但我在这个主题上没有足够的经验,无法知道我错在哪里。我想也许我应该使用Http_client.post_raw方法,但是我的顶层不能识别这个方法。我不确定如何继续纠正我的错误。
# Http_client.post_raw;;
Error: Unbound value Http_client.post_raw 提前谢谢。
发布于 2013-11-25 15:49:24
在使用HTTP API时,首先使用curl命令行实用程序测试API。一旦你得到一个预期的响应--实现代码来发送相同的请求和相同的头。请咨询curl -v和您的http库的调试工具。
发布于 2013-11-25 18:02:07
您的服务器可能有问题:
$ curl -v http://s1.ripple.com:51234/
* About to connect() to s1.ripple.com port 51234 (#0)
* Trying 54.200.86.207...
* Adding handle: conn: 0x7f92a1808c00
* Adding handle: send: 0
* Adding handle: recv: 0
* Curl_addHandleToPipeline: length: 1
* - Conn 0 (0x7f92a1808c00) send_pipe: 1, recv_pipe: 0
* Connected to s1.ripple.com (54.200.86.207) port 51234 (#0)
> GET / HTTP/1.1
> User-Agent: curl/7.32.0
> Host: s1.ripple.com:51234
> Accept: */*
>
* Empty reply from server
* Connection #0 to host s1.ripple.com left intact
curl: (52) Empty reply from server我经常使用OcamlNet,如果我可以建议你的话:之前在终端中用curl测试你的url。
https://stackoverflow.com/questions/20181388
复制相似问题