Bitcoin Forum
June 03, 2024, 06:42:33 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: PHP, jsonRPClient, bitcoind - Not able to pass multiple parameters  (Read 1487 times)
adamcol (OP)
Newbie
*
Offline Offline

Activity: 27
Merit: 0


View Profile
January 01, 2014, 05:05:44 PM
 #1

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:AJ2sa2cgGh2sVKUBuUCdALCcfNsM2VbLf37pmKEX7X3@99.233.34.168: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:AJ2sa2cgGh2sVKUBuUCdALCcfNsM2VbLf37pmKEX7X3@99.233.34.168: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?
elbandi
Hero Member
*****
Offline Offline

Activity: 525
Merit: 529


View Profile
January 01, 2014, 05:19:12 PM
 #2

catch the exception!
aceat64
Full Member
***
Offline Offline

Activity: 307
Merit: 102



View Profile
January 01, 2014, 10:59:50 PM
 #3

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
BCB
CTG
VIP
Legendary
*
Offline Offline

Activity: 1078
Merit: 1002


BCJ


View Profile
January 01, 2014, 11:04:04 PM
 #4

adamcol, does event he first of the three cmd's succeed or do they all fail?
aceat64
Full Member
***
Offline Offline

Activity: 307
Merit: 102



View Profile
January 05, 2014, 09:48:16 PM
 #5

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);
gweedo
Legendary
*
Offline Offline

Activity: 1498
Merit: 1000


View Profile
January 05, 2014, 09:51:38 PM
 #6

Did you add
Code:
allowip=<ip you are connecting from>

in your bitcoin.conf file.
gweedo
Legendary
*
Offline Offline

Activity: 1498
Merit: 1000


View Profile
January 05, 2014, 10:07:23 PM
 #7

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.
aceat64
Full Member
***
Offline Offline

Activity: 307
Merit: 102



View Profile
January 05, 2014, 10:50:38 PM
 #8

Do you have the curl extension installed? I haven't tested to see how the script behaves without it.
chiznitz
Hero Member
*****
Offline Offline

Activity: 574
Merit: 500


View Profile WWW
January 09, 2014, 03:46:28 PM
 #9

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.

Looking for the best exchange? -> https://bittrex.com
aceat64
Full Member
***
Offline Offline

Activity: 307
Merit: 102



View Profile
January 15, 2014, 12:53:50 AM
 #10

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
Shahrukh
Full Member
***
Offline Offline

Activity: 154
Merit: 100


View Profile WWW
January 15, 2014, 10:11:59 AM
 #11

Did you restart bitcoin daemon after making changes? Nothing will be effected until you restart bitcoind

I turned everyone down Sad Sorry for that
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!