Bitcoin Forum

Bitcoin => Bitcoin Technical Support => Topic started by: CoreQ on April 22, 2014, 03:08:41 PM



Title: Php Script
Post by: CoreQ on April 22, 2014, 03:08:41 PM
Does anyone have any php script /or what command to call that can get all incoming transactions using the rpc daemon? Thank you.


Title: Re: Php Script
Post by: ksteve96 on April 22, 2014, 10:55:01 PM
getreceivedbyaccount    [account] [minconf=1]
https://en.bitcoin.it/wiki/Original_Bitcoin_client/API_Calls_list#Full_list


Title: Re: Php Script
Post by: CoreQ on April 22, 2014, 11:26:06 PM
getreceivedbyaccount    [account] [minconf=1]
https://en.bitcoin.it/wiki/Original_Bitcoin_client/API_Calls_list#Full_list

I saw the API calls list but I dont know how to call it. for example getting the balance works

$bitcoin = new jsonRPCClient('http://test:test123@127.0.0.1:8332/');
$total = $bitcoin->getbalance();
echo "balance = $total";

If I call 'getinfo'

 $get = $bitcoin->getinfo();
 echo "Getinfo result: $get";


Notice: Array to string conversion in C:\xampp\htdocs\show balance\test.php on line 18
Getinfo result: Array


Title: Re: Php Script
Post by: zeflex on April 22, 2014, 11:45:41 PM

 echo "Getinfo result: $get";


Notice: Array to string conversion in C:\xampp\htdocs\show balance\test.php on line 18
Getinfo result: Array

You can't echo something if it's not an integer or a string.

Use
Code:
var_dump($get);
instead



Title: Re: Php Script
Post by: ksteve96 on April 23, 2014, 12:01:01 AM
what is on line 18? I don't see anything like $getinfo[]
 
Try making your title more specific too, probably nobody even reading this.  



Title: Re: Php Script
Post by: CoreQ on April 23, 2014, 12:06:28 AM

 echo "Getinfo result: $get";


Notice: Array to string conversion in C:\xampp\htdocs\show balance\test.php on line 18
Getinfo result: Array

You can't echo something if it's not an integer or a string.

Use
Code:
var_dump($get);
instead




Great now is working. Thank you.


what is on line 18? I don't see anything like $getinfo[]
 
Try making your title more specific too, probably nobody even reading this.  



Got the help I needed :)


Title: Re: Php Script
Post by: fbueller on April 24, 2014, 10:54:34 AM
Just to explain what's actually happening here: When you run a bitcoind command (not RPC yet), you are technically seeing the response in JSON.

When you're submitting using the jsonRPCclient, it takes care of dealing with the intermediary JSON for you. When you're playing with the createrawtransaction RPC call, you're not passing json strings as parameters, you pass arrays. The library takes care of converting to JSON, and decoding the response.

Hence, many RPC commands are expected to return an array (although not all)