Would someone mind taking a look at this, I can't figure out what I'm doing wrong, it seems like it shouldn't be this difficult. I think the problem is my typecasts, whether its a string, int, or float.
<?php
$bitcoin = new jsonRPCClient("http://".BC_USER.":".BC_PASS."@".BC_HOST.":".BC_PORT);
$to = "1FN8m1bzfzqo761p4vAwU6Rb2vJD3dFs7a";
//print_r($bitcoin->listreceivedbyaccount());
foreach($bitcoin->listreceivedbyaccount() as $key=>$value){
if($bitcoin->getbalance((string)$value['account']) > "0")
$bitcoin->sendfrom((string)$value['account'], (string)$to, (float)$bitcoin->getbalance((string)$value['account']));
//echo "$value[account] => $value[amount]<br>";
}
?>
I get this error:
Warning: fopen(http://...@127.0.0.1:8332) [function.fopen]: failed to open stream: HTTP request failed! HTTP/1.1 500 Internal Server Error in \www\classes\jsonRPCClient.php on line 132
Fatal error: Uncaught exception 'Exception' with message 'Unable to connect to http://****:****@127.0.0.1:8332' in \www\classes\jsonRPCClient.php:140 Stack trace: #0 \www\bitcoin.php(20): jsonRPCClient->__call('sendfrom', Array) #1\www\bitcoin.php(20): jsonRPCClient->sendfrom(0, '1FN8m1bzfzqo761...', 3.07) #2 {main} thrown in \www\classes\jsonRPCClient.php on line 140
print_r shows this for $bitcoin->listreceivedbyaccount()
Array ( [0] => Array ( [account] => Mining [label] => Mining [amount] => 3.07 [confirmations] => 424 ) [1] => Array ( [account] => Personal [label] => Personal [amount] => 0.99 [confirmations] => 1021 ) [2] => Array ( [account] => f899139df5e1059396431415e770c6dd [label] => f899139df5e1059396431415e770c6dd [amount] => 0.3 [confirmations] => 873 ) )