This works for me, here's a full example:
<?php
//I don't know which class and which version you use.
//To ensure that you're not running into incompatibility issues, I decided to includes this base class
class Bitcoin
{
public $id = 0;
public $host = "127.0.0.1";
public $port = 8332;
public $user = "<CHANGEME!>"; //Insert RPC username here
public $pass = "<CHANGEME!>"; //Insert RPC password here
public function __call($func, $param)
{
$data = json_encode(
array(
'id'=>$this->id++,
'method'=>$func,
'params'=>$param
)
);
$ch = curl_init("http://".$this->host.":".$this->port."");
if ($ch)
{
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERPWD, rawurlencode($this->user).":".rawurlencode($this->pass));
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$out = curl_exec($ch);
$error = curl_error($ch);
curl_close($ch);
if ($error)
{
throw new Exception($error);
}
$decoded = json_decode($out);
if ($decoded === null)
{
throw new Exception("Malformed JSON: $out");
}
return $decoded;
}
else
{
throw new Exception(curl_error($ch));
}
}
}
$bitcoin = new Bitcoin();
$count = 2;
$offset = 0;
//Here's the actual code which groups the transaction
header("Content-Type: text/html; charset=UTF-8");
echo "<html><body>";
echo "<h1>Transactions</h1>";
while (true)
{
//First parameter: Account, * = all
//Second parameter: Max count
//Third parameter: Offset
$result = $bitcoin->listtransactions('*', $count, $offset);
if (!$result->result) break;
echo "<h2>Tranaction at offset $offset, max count $count</h2>";
echo "<pre>".htmlspecialchars(print_r($result, true))."</pre>";
$offset += $count;
}
echo "</body></html>";
This is the change:
$count = 5; $offset = 0;
$bitcoin->listtransactions('*', $count, $offset); //$bitcoin->listtransactions('*', 5, 0); works of course too
instead of:
$bitcoin->listtransactions("count = 5, offset = 0");
I hope this helps.
As soon as you confirm that it works, my address is 1EwKrY5Bn3T47r4tYqSv6mMQkUyu7hZckV as in the signature