Author

Topic: Help with blockchain.info JSON RPC API?? (Read 4232 times)

legendary
Activity: 3612
Merit: 1564
May 10, 2013, 06:57:25 PM
#12
Also, FYI, blockchain.info has a second API called a merchants API. You can see it here:

http://blockchain.info/api/blockchain_wallet_api

Of course you still need openssl installed.
legendary
Activity: 3612
Merit: 1564
You need to install the openssl PHP extension. You can check whether you have it installed by running the following command on the linux command line:

Code:
php -m |grep openssl

If the above command displays nothing that means you don't have openssl installed.

How you install it depends on your linux distro.
newbie
Activity: 30
Merit: 0
In the documentation (https://blockchain.info/api/json_rpc_api) I see -rpcssl Set to use a secure connection (Recommended), how can I set this in the code above? Thanks for the info about url encode Smiley

As far as I know, when you specify "https://" you should automatically connect with SSL enabled (I'm not a PHP programmer). You can check it by connecting to non-ssl site (e.g. you own local webserver) using "https://" prefix, if it gives error then it works fine.

Unfortunately doing this does not seem to work in this case.
sr. member
Activity: 309
Merit: 250
In the documentation (https://blockchain.info/api/json_rpc_api) I see -rpcssl Set to use a secure connection (Recommended), how can I set this in the code above? Thanks for the info about url encode Smiley

As far as I know, when you specify "https://" you should automatically connect with SSL enabled (I'm not a PHP programmer). You can check it by connecting to non-ssl site (e.g. you own local webserver) using "https://" prefix, if it gives error then it works fine.
newbie
Activity: 30
Merit: 0
In the documentation (https://blockchain.info/api/json_rpc_api) I see -rpcssl Set to use a secure connection (Recommended), how can I set this in the code above? Thanks for the info about url encode Smiley
sr. member
Activity: 309
Merit: 250
You can use strong password with special symbools and spaces but you need to encode it before using as a part of URL. Use http://php.net/manual/en/function.urlencode.php on your URL and it will work fine. No need to use weaker password.
sr. member
Activity: 309
Merit: 250
If I change the code and port to this:

Code:

/* Configuration variables for the JSON-RPC server */
$rpc_host 'rpc.blockchain.info';
$rpc_port '443';
$rpc_user 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX';
$rpc_pass 'PASSWORD';


require_once(
'jsonRPCClient.php');
$bc = new jsonRPCClient('https://' $rpc_user ':' $rpc_pass '@' $rpc_host ':' $rpc_port);

$balance $bc->getbalance();

?>

It will not connect??

It should. You don't need to buy certificate in order to connect to HTTPS server. You need to buy it only if want to own a server with SSL support/
newbie
Activity: 30
Merit: 0
If I change the code and port to this:

Code:

/* Configuration variables for the JSON-RPC server */
$rpc_host 'rpc.blockchain.info';
$rpc_port '443';
$rpc_user 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX';
$rpc_pass 'PASSWORD';


require_once(
'jsonRPCClient.php');
$bc = new jsonRPCClient('https://' $rpc_user ':' $rpc_pass '@' $rpc_host ':' $rpc_port);

$balance $bc->getbalance();

?>

It will not connect??
legendary
Activity: 3612
Merit: 1564
I meant use https://rpc.blockchain... instead of http://rpc.block... in your call to the jsonrpc constructor.
newbie
Activity: 30
Merit: 0
Use https instead of http or your password is passed in plain text.

How do you do this? By buying an SSL cert for the domain and using port 443??

Sorry I have never used https when building websites before, thanks.
legendary
Activity: 3612
Merit: 1564
Use https instead of http or your password is passed in plain text.
newbie
Activity: 30
Merit: 0
Hi,

I have opened a blockchain.info wallet in the hope of using their JSON RPC API for a website project, and am trying to use code below to show the balance of the wallet on my website to test the water.

Code:

/* Configuration variables for the JSON-RPC server */
$rpc_host 'rpc.blockchain.info';
$rpc_port '80';
$rpc_user 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX';
$rpc_pass 'PASSWORD';


require_once(
'jsonRPCClient.php');
$bc = new jsonRPCClient('http://' $rpc_user ':' $rpc_pass '@' $rpc_host ':' $rpc_port);

$balance $bc->getbalance();

?>

However I get these errors:

Code:
Warning: fopen(http://[email protected]:80) [function.fopen]: failed to open stream: operation failed in /home/*****/public_html/*****/jsonRPCClient.php on line 132

Fatal error: Uncaught exception 'Exception' with message 'Unable to connect to http://XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX:[email protected]:80' in /home/a*****/public_html/*****/jsonRPCClient.php:140 Stack trace: #0 /home/*****/public_html/*****/index.php(18): jsonRPCClient->__call('getbalance', Array) #1 /home/*****/public_html/*****/index.php(18): jsonRPCClient->getbalance() #2 {main} thrown in /home/*****/public_html/*****/jsonRPCClient.php on line 140

Does anybody have any idea what I am doing wrong?

EDIT SOLVED: I was using a strong password with various symbols (*#; etc..) in for the blockchain wallet and it did not seem to like this.
Jump to: