hi want to connect rpc.blockchain.info by java
-> https://blockchain.info/api/json_rpc_api
for json-rpc using jsonrpc4j lib
-> https://github.com/briandilley/jsonrpc4j
my source result
Exception in thread "main" com.googlecode.jsonrpc4j.HttpException: {"error":{"message":"JSON-RPC method [getinfo] with 0 parameters not found.","code":-32601},"jsonrpc":"2.0"}
at com.googlecode.jsonrpc4j.JsonRpcHttpClient.invoke(JsonRpcHttpClient.java:165)
at com.googlecode.jsonrpc4j.JsonRpcHttpClient.invoke(JsonRpcHttpClient.java:105)
at com.googlecode.jsonrpc4j.JsonRpcHttpClient.invoke(JsonRpcHttpClient.java:123)
at com.option.bitcoin.AppTest2.main(AppTest2.java:55)
Caused by: java.io.IOException: Server returned HTTP response code: 401 for URL: http://rpc.blockchain.info:80
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at com.googlecode.jsonrpc4j.JsonRpcHttpClient.invoke(JsonRpcHttpClient.java:157)
... 3 more
i think not connectiong to rpc.blockchain.info
how i can do?
I'm sorry that I can not not speak English well
because i from south korea
help me plz~~
below my java source
import java.net.PasswordAuthentication;
import java.net.URL;
import com.googlecode.jsonrpc4j.JsonRpcHttpClient;
import org.json.simple.*;
/**
* Unit test for simple App.
*/
public class AppTest2
{
public static void main(String args[]) throws Throwable
{
final String rpcuser ="id";
final String rpcpassword ="pwd";
Authenticator.setDefault(new Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication (rpcuser, rpcpassword.toCharArray());
}
});
JsonRpcHttpClient client = null;
try {
client = new JsonRpcHttpClient(new URL("http://rpc.blockchain.info:80"));
} catch (Exception e) {
e.printStackTrace();
} catch (Throwable t) {
t.printStackTrace();
}//end try/catch
String temp = client.invoke("getinfo",null,String.class);
System.out.println("temp=="+temp);
}
}