Bitcoin Institute

PHP, jsonRPClient, bitcoind - Not able to pass multiple parameters

4 messages BitcoinTalk Andrew LeCody January 1, 2014 — January 15, 2014

The jsonRPCClient library uses fopen() and will throw an exception saying “Unable to connect” if it receives a 404 or 500 error from bitcoind. This prevents you from being able to see error messages generated by bitcoind (as they are sent with status 404 or 500).

I wrote a replacement for jsonRPCClient specifically for Bitcoin, if you run into any issues with it let me know: https://github.com/aceat64/EasyBitcoin-PHP

Try using var_dump instead of echo. The output of getinfo() should be an array.

$bitcoin = new Bitcoin('bitcoinrpc','RPC_PASSWORD', 'x.x.x.x','51337', 'http');
$bitcoin->full = true;
var_dump($bitcoin->getinfo());
var_dump($bitcoin->error);

Do you have the curl extension installed? I haven’t tested to see how the script behaves without it.

I’ve reworked my library to make more sense and fixed some major bugs. Namely, I wasn’t handling things well if cURL ran into an issue.

  • Errors are now properly handled if cURL runs into a problem (e.g. can’t resolve hostname)
  • Methods now always return false when they don’t work.
  • HTTP status codes are available in $this->status
  • Human readable error messages are available in $this->error
  • Full response is available in $this->response
  • Raw response (JSON) is available in $this->raw_response