Author

Topic: PHP, jsonRPClient, bitcoind - Not able to pass multiple parameters (Read 1509 times)

full member
Activity: 154
Merit: 100
Did you restart bitcoin daemon after making changes? Nothing will be effected until you restart bitcoind
full member
Activity: 307
Merit: 102
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
hero member
Activity: 574
Merit: 500
I won't get into my overall issues but I'm having the same issue with easybitcoin.php not placing the error into bitcoin->error.

It returns 0 no matter how I print it.

                        var_dump($bitcoin2->error);
                        print_r($bitcoin2->error);
I broke the address on purpose, when I fix the address it works just fine

the curl dll is installed for php, however I am running on windows during development.
full member
Activity: 307
Merit: 102
Do you have the curl extension installed? I haven't tested to see how the script behaves without it.
legendary
Activity: 1498
Merit: 1000
Try using var_dump instead of echo. The output of getinfo() should be an array.

Code:
$bitcoin = new Bitcoin('bitcoinrpc','AJ2sa2cgGh2sVKUBuUCdALCcfNsM2VbLf37pmKEX7Xh3', '99.233.34.168','51337', 'http');
$bitcoin->full = true;
var_dump($bitcoin->getinfo());
var_dump($bitcoin->error);

Hey - I get a bool(false) with that PHP command.

Yes 0 in php means false, when not casted.
legendary
Activity: 1498
Merit: 1000
Did you add
Code:
allowip=

in your bitcoin.conf file.
full member
Activity: 307
Merit: 102
Try using var_dump instead of echo. The output of getinfo() should be an array.

Code:
$bitcoin = new Bitcoin('bitcoinrpc','AJ2sa2cgGh2sVKUBuUCdALCcfNsM2VbLf37pmKEX7Xh3', '99.233.34.168','51337', 'http');
$bitcoin->full = true;
var_dump($bitcoin->getinfo());
var_dump($bitcoin->error);
BCB
vip
Activity: 1078
Merit: 1002
BCJ
adamcol, does event he first of the three cmd's succeed or do they all fail?
full member
Activity: 307
Merit: 102
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
hero member
Activity: 525
Merit: 531
catch the exception!
newbie
Activity: 27
Merit: 0
Hoping someone has an answer to this rather strange issue.

I've got bitcoind running, and connected to my web service via rpc. Commands like this work fine:

Code:
require_once 'jsonRPCClient.php';
 
$bitcoin = new jsonRPCClient('http://bitcoinrpc:[email protected]:51337');
  
$result = $bitcoin->getinfo();
$resulttwo = $bitcoin->getnewaddress("test");

print_r($result);

print_r($resulttwo);

As soon as I use any command that passes two or more arguments, it dies full stop with no errors or anything. Debug.log claims a connection timeout. Eg:

Code:

require_once 'jsonRPCClient.php';
 
$bitcoin = new jsonRPCClient('http://bitcoinrpc:[email protected]:51337');
  
$result = $bitcoin->getinfo();
$resulttwo = $bitcoin->getnewaddress("test");
$resultthree = $bitcoin->getbalance("test", "6");

print_r($result);

print_r($resulttwo);

print_r($resultthree);


I've tried using single quotes, double quotes, no quotes, an array, and a different server..

Any ideas?
Jump to: