2013-11-24 37 views
0

我想写一些代码来检索我的帐户状态从波纹API(https://ripple.com/wiki/JSON_Messages)。我正在使用的代码:OCamlnet和波纹API

#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   

在此先感谢。

+0

即使在浏览器中,您提供的URL也不会返回任何数据。 –

回答

2

首先使用HTTP API并首先使用curl命令行实用程序测试API。一旦你得到预期的响应 - 实现代码发送相同的请求相同的头。请使用curl -v和http库的调试工具进行检查。

1

有可能出错服务器:

$ 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了很多,如果我可以告诉你:之前测试的卷曲您的网址在终端。