Bitcoin Forum
September 27, 2018, 11:07:39 PM *
News: ♦♦ New info! Bitcoin Core users absolutely must upgrade to previously-announced 0.16.3 [Torrent]. All Bitcoin users should temporarily trust confirmations slightly less. More info.
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: PHP, jsonRPClient, bitcoind - Not able to pass multiple parameters  (Read 1424 times)
adamcol
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?
1538089659
Hero Member
*
Offline Offline

Posts: 1538089659

View Profile Personal Message (Offline)

Ignore
1538089659
Reply with quote  #2

1538089659
Report to moderator
1538089659
Hero Member
*
Offline Offline

Posts: 1538089659

View Profile Personal Message (Offline)

Ignore
1538089659
Reply with quote  #2

1538089659
Report to moderator
1538089659
Hero Member
*
Offline Offline

Posts: 1538089659

View Profile Personal Message (Offline)

Ignore
1538089659
Reply with quote  #2

1538089659
Report to moderator
Make a difference with your Ether.
Donate Ether for the greater good.
SPRING.WETRUST.IO
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1538089659
Hero Member
*
Offline Offline

Posts: 1538089659

View Profile Personal Message (Offline)

Ignore
1538089659
Reply with quote  #2

1538089659
Report to moderator
1538089659
Hero Member
*
Offline Offline

Posts: 1538089659

View Profile Personal Message (Offline)

Ignore
1538089659
Reply with quote  #2

1538089659
Report to moderator
1538089659
Hero Member
*
Offline Offline

Posts: 1538089659

View Profile Personal Message (Offline)

Ignore
1538089659
Reply with quote  #2

1538089659
Report to moderator
elbandi
Hero Member
*****
Offline Offline

Activity: 515
Merit: 503


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

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

Activity: 310
Merit: 101



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: 1064
Merit: 1000


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: 310
Merit: 101



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: 1246
Merit: 1000


Java, PHP, HTML/CSS Programmer for Hire!


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

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

in your bitcoin.conf file.

Want to earn 2500 SATOSHIS per hour? Come Chat and Chill in https://goseemybits.com/lobby
gweedo
Legendary
*
Offline Offline

Activity: 1246
Merit: 1000


Java, PHP, HTML/CSS Programmer for Hire!


View Profile WWW
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.

Want to earn 2500 SATOSHIS per hour? Come Chat and Chill in https://goseemybits.com/lobby
aceat64
Full Member
***
Offline Offline

Activity: 310
Merit: 101



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: 310
Merit: 101



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:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!