<p>The jsonRPC client does not handle errors from bitcoind well. <a href="https://en.bitcoin.it/wiki/API_reference_(JSON-RPC)#PHP" rel="nofollow">source</a></p>

<p>Instead it is recommended to use the easybitcoin php library, available on github <a href="https://github.com/aceat64/EasyBitcoin-PHP" rel="nofollow">here</a>. It's usage is simple and it outputs 404 and 500 errors properly. </p>

<pre><code>require("easybitcoin.php");
$bitcoin = new Bitcoin("someusername", "somepassword");

$txid = $_GET["tx"];
$txinfo = $bitcoin-&gt;gettransaction($txid);
$amount = $txinfo["amount"]; 
echo $amount ? $amount : $bitcoin-&gt;error;
</code></pre>

CC BY-SA 3.0
2016-04-21T01:59:27.587Z
2016-04-21T02:08:09.140Z
2016-04-21T02:08:09.140Z
m1xolyd1an
<p>I use bitcoind. And I have simple bitcoin wallet with simple login-register system.</p>

<p>Error Code;</p>

<pre><code>Fatal error: Uncaught exception 'Exception' with message 'Incorrect response id (request id: 1, response id: )' in /var/www/ponzi/htdocs/wallet/includes/jsonRPCClient.php:146 Stack trace: #0 /var/www/ponzi/htdocs/wallet/account.php(38): jsonRPCClient-&gt;__call('getaccountaddre...', Array) #1 /var/www/ponzi/htdocs/wallet/account.php(38): jsonRPCClient-&gt;getaccountaddress('kaka') #2 {main} thrown in /var/www/ponzi/htdocs/wallet/includes/jsonRPCClient.php on line 146
</code></pre>

<p>Account Page;</p>

<pre><code>&lt;?php include("includes/auth.php"); //include auth.php file on all secure pages ?&gt;
&lt;html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"&gt;
    &lt;head&gt;
        &lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /&gt;
        &lt;title&gt;MyCoinWallet - Account&lt;/title&gt;
        &lt;link rel="stylesheet" href="css/styles.css"  type="text/css" /&gt;
    &lt;/head&gt;
    &lt;body&gt;
        &lt;div id="main"&gt;
            &lt;div id="top"&gt;&lt;div style='float:left;position:relative;top:25px;'&gt;&lt;h2&gt;MyCoinWallet&lt;/h2&gt;&lt;/div&gt;&lt;div class="logomargin"&gt;&lt;img src='images/logo-mockup2.png' /&gt;&lt;/div&gt;&lt;/div&gt;
            &lt;div id="wrapper"&gt;
                &lt;div id="content"&gt;
                    &lt;div class="innermargin"&gt;
                        &lt;h1&gt;MyCoinWallet Account&lt;/h1&gt;
                        &lt;br /&gt;
                        &lt;form&gt;
                            &lt;br&gt;
                            &lt;p&gt;Welcome &lt;?php echo $_SESSION['username']; ?&gt;!&lt;/p&gt;&lt;br&gt;&lt;br&gt;

                            &lt;?php
                            require_once('includes/db.php');
                            require_once('includes/config.php');
                            require_once('includes/jsonRPCClient.php');
                            require_once('includes/bcfunctions.php');

                            $bitcoin = new jsonRPCClient('http://MYUSER:MYPASS@localhost:8332');

                            $kadi = $_SESSION['username'];


                            // check for session address
                            if(isset($_SESSION['sendaddress'])) {
                                $sendaddress = refreshAddressIfStale($bitcoin,$_SESSION['sendaddress']); // session exists, check if its been used before
                                $_SESSION['sendaddress'] = $sendaddress;
                            } else {
                                // if address already exists in wallet (or new unfortunately), check the balance and set as main receivable address if zero
                                $curaddress = $bitcoin-&gt;getaccountaddress($kadi);
                                $sendaddress = refreshAddressIfStale($bitcoin,$curaddress);
                                $_SESSION['sendaddress'] = $sendaddress;
                            }

                            // save current balance
                            saveCurrentBalance($bitcoin, $_SESSION['sendaddress']);

                            $userBalance = $_SESSION['userbalance'];
                            $singleconfirmBalance = number_format($bitcoin-&gt;getbalance($_SESSION['username'], 0),8); // set to zero, this is near instant, set to one one on the side of caution
                            if($singleconfirmBalance &gt; 0) {     // user has unconfirmed transactions
                                $unconfirmedBalance = $singleconfirmBalance - $userBalance;
                            }
                            echo "Current Balance: ". $userBalance ."&lt;br /&gt;";
                            if((isset($unconfirmedBalance)) &amp;&amp; ($unconfirmedBalance &gt; 0)) {
                                echo "Unconfirmed Balance: ". $unconfirmedBalance ."&lt;br /&gt;";
                            }

                            echo "&lt;h2&gt;Recent Transactions:&lt;/h2&gt;&lt;table&gt;";
                            $transactions = $bitcoin-&gt;listtransactions($_SESSION['username']);
                            foreach($transactions as $trans) {
                                if(isset($trans['account'])) {
                                    $transacct = $trans['account'];
                                } else {
                                    $transacct = '';
                                }
                                if(isset($trans['address'])) {
                                    $transaddress = $trans['address'];
                                } else {
                                    $transaddress = '';
                                }
                                if(isset($trans['category'])) {
                                    $transcategory = $trans['category'];
                                } else {
                                    $transcategory = '';
                                }
                                if(isset($trans['amount'])) {
                                    $transamount = $trans['amount'];
                                } else {
                                    $transamount = '';
                                }
                                if(isset($trans['confirmations'])) {
                                    $transconfirmations = $trans['confirmations'];
                                } else {
                                    $transconfirmations = '';
                                }
                                if(isset($trans['blockhash'])) {
                                    $transblockhash = $trans['blockhash'];
                                } else {
                                    $transblockhash = '';
                                }
                                if(isset($trans['blockindex'])) {
                                    $transblockindex = $trans['blockindex'];
                                } else {
                                    $transblockindex = '';
                                }
                                if(isset($trans['blocktime'])) {
                                    $transblocktime = $trans['blocktime'];
                                } else {
                                    $transblocktime = '';
                                }
                                if(isset($trans['txid'])) {
                                    $transtxid = $trans['txid'];
                                } else {
                                    $transtxid = '';
                                }
                                if(isset($trans['time'])) {
                                    $transtime = $trans['time'];
                                } else {
                                    $transtime = '';
                                }
                                if(isset($trans['timereceived'])) {
                                    $transtimereceived = $trans['timereceived'];
                                } else {
                                    $transtimereceived = '';
                                }
                                /*
                                $transaddress = $trans['address'];
                                $transcategory = $trans['category'];
                                $transamount = $trans['amount'];
                                $transconfirmations = $trans['confirmations'];
                                $transblockhash = $trans['blockhash'];
                                $transblockindex = $trans['blockindex'];
                                $transblocktime = $trans['blocktime'];
                                $transtxid = $trans['txid'];
                                $transtime = $trans['time'];
                                $transtimereceived = $trans['timereceived'];
                                */

                                echo "&lt;tr&gt;&lt;td&gt;Address:&lt;/td&gt;&lt;td&gt;". $transaddress ."&lt;/td&gt;&lt;/tr&gt;";
                                echo "&lt;tr&gt;&lt;td&gt;Amount:&lt;/td&gt;&lt;td&gt;". number_format($transamount, 8) ."&lt;/td&gt;&lt;/tr&gt;";
                                echo "&lt;tr&gt;&lt;td&gt;Category:&lt;/td&gt;&lt;td&gt;". $transcategory ."&lt;/td&gt;&lt;/tr&gt;";
                                echo "&lt;tr&gt;&lt;td&gt;Confirmations:&lt;/td&gt;&lt;td&gt;". $transconfirmations ."&lt;/td&gt;&lt;/tr&gt;";
                                echo "&lt;tr&gt;&lt;td&gt;Blockhash:&lt;/td&gt;&lt;td&gt;". $transblockhash ."&lt;/td&gt;&lt;/tr&gt;";
                                echo "&lt;tr&gt;&lt;td&gt;txid:&lt;/td&gt;&lt;td&gt;". $transtxid ."&lt;/td&gt;&lt;/tr&gt;";
                                echo "&lt;tr&gt;&lt;td&gt;Time:&lt;/td&gt;&lt;td&gt;". date("Y - M - d H:i:s", $transtime) ."&lt;/td&gt;&lt;/tr&gt;";
                                echo "&lt;tr&gt;&lt;td&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;";
                            }
                            ?&gt;
                        &lt;/table&gt;&lt;/form&gt;
                    &lt;/div&gt;
                &lt;/div&gt;
            &lt;/div&gt;
            &lt;div id="menu"&gt;
                &lt;div class="menumargin"&gt;
                    &lt;a href='index.php'&gt;Home&lt;/a&gt;
                    &lt;a href='account.php'&gt;Account&lt;/a&gt;
                    &lt;a href='deposit.php'&gt;Deposit&lt;/a&gt;
                    &lt;a href='withdraw.php'&gt;Withdraw&lt;/a&gt;
                    &lt;a href='contact.php'&gt;Contact&lt;/a&gt;
                    &lt;a href='#'&gt;Logout&lt;/a&gt;
                &lt;/div&gt;
            &lt;/div&gt;
            &lt;div id="footer"&gt;&lt;a href="index.php"&gt;Home&lt;/a&gt; | &lt;a href="account.php"&gt;Account&lt;/a&gt; | &lt;a href="deposit.php"&gt;Deposit&lt;/a&gt; | &lt;a href="withdraw.php"&gt;Withdraw&lt;/a&gt; | &lt;a href="contact.php"&gt;Contact&lt;/a&gt; | &lt;a href="#"&gt;Logout&lt;/a&gt; | &lt;/div&gt;
        &lt;/div&gt;
    &lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>jsonRPCClient.php;</p>

<pre><code>    &lt;?php
/*
                    COPYRIGHT

Copyright 2007 Sergio Vaccaro &lt;sergio@inservibile.org&gt;

This file is part of JSON-RPC PHP.

JSON-RPC PHP is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

JSON-RPC PHP is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with JSON-RPC PHP; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/

/**
 * The object of this class are generic jsonRPC 1.0 clients
 * http://json-rpc.org/wiki/specification
 *
 * @author sergio &lt;jsonrpcphp@inservibile.org&gt;
 */

 /* converted old fopen method to curl and added ability to use ssl - Galen */

class jsonRPCClient {  
    /**
     * Debug state
     *
     * @var boolean
     */
    private $debug;

    /**
     * The server URL
     *
     * @var string
     */
    private $url;
    /**
     * The request id
     *
     * @var integer
     */
    private $id;
    /**
     * If true, notifications are performed instead of requests
     *
     * @var boolean
     */
    private $notification = false;

    /**
     * Takes the connection parameters
     *
     * @param string $url
     * @param boolean $debug
     */
    public function __construct($url,$debug = false) {
        // server URL
        $this-&gt;url = $url;
        // proxy
        empty($proxy) ? $this-&gt;proxy = '' : $this-&gt;proxy = $proxy;
        // debug state
        empty($debug) ? $this-&gt;debug = false : $this-&gt;debug = true;
        // message id
        $this-&gt;id = 1;
    }

    /**
     * Sets the notification state of the object. In this state, notifications are performed, instead of requests.
     *
     * @param boolean $notification
     */
    public function setRPCNotification($notification) {
        empty($notification) ?
        $this-&gt;notification = false
        :
        $this-&gt;notification = true;
    }

    /**
     * Performs a jsonRCP request and gets the results as an array
     *
     * @param string $method
     * @param array $params
     * @return array
     */
        public function __call($method,$params) {
        // check
        if (!is_scalar($method)) {
            throw new Exception('Method name has no scalar value');
        }

        // check
        if (is_array($params)) {
            // no keys
            $params = array_values($params);
        } else {
            throw new Exception('Params must be given as array');
        }

        // sets notification or request task
        if ($this-&gt;notification) {
            $currentId = NULL;
        } else {
            $currentId = $this-&gt;id;
        }

        // prepares the request
        $request = array(
            'method' =&gt; $method,
            'params' =&gt; $params,
            'id' =&gt; $currentId
        );
        $request = json_encode($request);
        $this-&gt;debug &amp;&amp; $this-&gt;debug='***** Request *****'."\n".$request."\n".'***** End Of request *****'."\n\n";

        // performs the HTTP POST
        $ch = curl_init($this-&gt;url);
        // curl ssl options
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: application/json'));
        curl_setopt($ch, CURLOPT_POST, true);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
        $response = json_decode(curl_exec($ch),true);
        curl_close($ch);
        // debug output
        if ($this-&gt;debug) {
            echo nl2br($this-&gt;debug);
        }

        // final checks and return
        if (!$this-&gt;notification) {
            // check
            if ($response['id'] != $currentId) {
                throw new Exception('Incorrect response id (request id: '.$currentId.', response id: '.$response['id'].')');
            }
            if (!is_null($response['error'])) {
                throw new Exception('Request error: '.$response['error']);
            }
            return $response['result'];
        } else {
            return true;
        }
    }
}
?&gt;
</code></pre>

<p>Please help me!!</p>

CC BY-SA 3.0
2016-08-19T10:14:29.133Z
WOW a ponzi /var/www/ponzi/htdocs/wallet/account.php just wow.....
Web Weave
CC BY-SA 4.0
2019-09-03T08:19:50.460Z
may be server owner is just called Carlo?
Nick
<bitcoind><json-rpc><connection>
JSON-RPC Connection Problem!
Cihan Sancak
# JSON-RPC Connection Problem!

(Asked by: username_0 on 2016-04-18)

I use bitcoind. And I have simple bitcoin wallet with simple login-register system.

Error Code;

```
Fatal error: Uncaught exception 'Exception' with message 'Incorrect response id (request id: 1, response id: )' in /var/www/ponzi/htdocs/wallet/includes/jsonRPCClient.php:146 Stack trace: #0 /var/www/ponzi/htdocs/wallet/account.php(38): jsonRPCClient->__call('getaccountaddre...', Array) #1 /var/www/ponzi/htdocs/wallet/account.php(38): jsonRPCClient->getaccountaddress('kaka') #2 {main} thrown in /var/www/ponzi/htdocs/wallet/includes/jsonRPCClient.php on line 146

```

Account Page;

```
<?php include("includes/auth.php"); //include auth.php file on all secure pages ?>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
        <title>MyCoinWallet - Account</title>
        <link rel="stylesheet" href="css/styles.css"  type="text/css" />
    </head>
    <body>
        <div id="main">
            <div id="top"><div style='float:left;position:relative;top:25px;'><h2>MyCoinWallet</h2></div><div class="logomargin"><img src='images/logo-mockup2.png' /></div></div>
            <div id="wrapper">
                <div id="content">
                    <div class="innermargin">
                        <h1>MyCoinWallet Account</h1>
                        <br />
                        <form>
                            <br>
                            <p>Welcome <?php echo $_SESSION['username']; ?>!</p><br><br>

                            <?php
                            require_once('includes/db.php');
                            require_once('includes/config.php');
                            require_once('includes/jsonRPCClient.php');
                            require_once('includes/bcfunctions.php');

                            $bitcoin = new jsonRPCClient('http://MYUSER:MYPASS@localhost:8332');

                            $kadi = $_SESSION['username'];

                            // check for session address
                            if(isset($_SESSION['sendaddress'])) {
                                $sendaddress = refreshAddressIfStale($bitcoin,$_SESSION['sendaddress']); // session exists, check if its been used before
                                $_SESSION['sendaddress'] = $sendaddress;
                            } else {
                                // if address already exists in wallet (or new unfortunately), check the balance and set as main receivable address if zero
                                $curaddress = $bitcoin->getaccountaddress($kadi);
                                $sendaddress = refreshAddressIfStale($bitcoin,$curaddress);
                                $_SESSION['sendaddress'] = $sendaddress;
                            }

                            // save current balance
                            saveCurrentBalance($bitcoin, $_SESSION['sendaddress']);

                            $userBalance = $_SESSION['userbalance'];
                            $singleconfirmBalance = number_format($bitcoin->getbalance($_SESSION['username'], 0),8); // set to zero, this is near instant, set to one one on the side of caution
                            if($singleconfirmBalance > 0) {     // user has unconfirmed transactions
                                $unconfirmedBalance = $singleconfirmBalance - $userBalance;
                            }
                            echo "Current Balance: ". $userBalance ."<br />";
                            if((isset($unconfirmedBalance)) && ($unconfirmedBalance > 0)) {
                                echo "Unconfirmed Balance: ". $unconfirmedBalance ."<br />";
                            }

                            echo "<h2>Recent Transactions:</h2><table>";
                            $transactions = $bitcoin->listtransactions($_SESSION['username']);
                            foreach($transactions as $trans) {
                                if(isset($trans['account'])) {
                                    $transacct = $trans['account'];
                                } else {
                                    $transacct = '';
                                }
                                if(isset($trans['address'])) {
                                    $transaddress = $trans['address'];
                                } else {
                                    $transaddress = '';
                                }
                                if(isset($trans['category'])) {
                                    $transcategory = $trans['category'];
                                } else {
                                    $transcategory = '';
                                }
                                if(isset($trans['amount'])) {
                                    $transamount = $trans['amount'];
                                } else {
                                    $transamount = '';
                                }
                                if(isset($trans['confirmations'])) {
                                    $transconfirmations = $trans['confirmations'];
                                } else {
                                    $transconfirmations = '';
                                }
                                if(isset($trans['blockhash'])) {
                                    $transblockhash = $trans['blockhash'];
                                } else {
                                    $transblockhash = '';
                                }
                                if(isset($trans['blockindex'])) {
                                    $transblockindex = $trans['blockindex'];
                                } else {
                                    $transblockindex = '';
                                }
                                if(isset($trans['blocktime'])) {
                                    $transblocktime = $trans['blocktime'];
                                } else {
                                    $transblocktime = '';
                                }
                                if(isset($trans['txid'])) {
                                    $transtxid = $trans['txid'];
                                } else {
                                    $transtxid = '';
                                }
                                if(isset($trans['time'])) {
                                    $transtime = $trans['time'];
                                } else {
                                    $transtime = '';
                                }
                                if(isset($trans['timereceived'])) {
                                    $transtimereceived = $trans['timereceived'];
                                } else {
                                    $transtimereceived = '';
                                }
                                /*
                                $transaddress = $trans['address'];
                                $transcategory = $trans['category'];
                                $transamount = $trans['amount'];
                                $transconfirmations = $trans['confirmations'];
                                $transblockhash = $trans['blockhash'];
                                $transblockindex = $trans['blockindex'];
                                $transblocktime = $trans['blocktime'];
                                $transtxid = $trans['txid'];
                                $transtime = $trans['time'];
                                $transtimereceived = $trans['timereceived'];
                                */

                                echo "<tr><td>Address:</td><td>". $transaddress ."</td></tr>";
                                echo "<tr><td>Amount:</td><td>". number_format($transamount, 8) ."</td></tr>";
                                echo "<tr><td>Category:</td><td>". $transcategory ."</td></tr>";
                                echo "<tr><td>Confirmations:</td><td>". $transconfirmations ."</td></tr>";
                                echo "<tr><td>Blockhash:</td><td>". $transblockhash ."</td></tr>";
                                echo "<tr><td>txid:</td><td>". $transtxid ."</td></tr>";
                                echo "<tr><td>Time:</td><td>". date("Y - M - d H:i:s", $transtime) ."</td></tr>";
                                echo "<tr><td>&nbsp;</td></tr>";
                            }
                            ?>
                        </table></form>
                    </div>
                </div>
            </div>
            <div id="menu">
                <div class="menumargin">
                    <a href='index.php'>Home</a>
                    <a href='account.php'>Account</a>
                    <a href='deposit.php'>Deposit</a>
                    <a href='withdraw.php'>Withdraw</a>
                    <a href='contact.php'>Contact</a>
                    <a href='#'>Logout</a>
                </div>
            </div>
            <div id="footer"><a href="index.php">Home</a> | <a href="account.php">Account</a> | <a href="deposit.php">Deposit</a> | <a href="withdraw.php">Withdraw</a> | <a href="contact.php">Contact</a> | <a href="#">Logout</a> | </div>
        </div>
    </body>
</html>

```

jsonRPCClient.php;

```
    <?php
/*
                    COPYRIGHT

Copyright 2007 Sergio Vaccaro <sergio@inservibile.org>

This file is part of JSON-RPC PHP.

JSON-RPC PHP is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

JSON-RPC PHP is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with JSON-RPC PHP; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/

/**
 * The object of this class are generic jsonRPC 1.0 clients
 * http://json-rpc.org/wiki/specification
 *
 * @author sergio <jsonrpcphp@inservibile.org>
 */

 /* converted old fopen method to curl and added ability to use ssl - Galen */

class jsonRPCClient {  
    /**
     * Debug state
     *
     * @var boolean
     */
    private $debug;

    /**
     * The server URL
     *
     * @var string
     */
    private $url;
    /**
     * The request id
     *
     * @var integer
     */
    private $id;
    /**
     * If true, notifications are performed instead of requests
     *
     * @var boolean
     */
    private $notification = false;

    /**
     * Takes the connection parameters
     *
     * @param string $url
     * @param boolean $debug
     */
    public function __construct($url,$debug = false) {
        // server URL
        $this->url = $url;
        // proxy
        empty($proxy) ? $this->proxy = '' : $this->proxy = $proxy;
        // debug state
        empty($debug) ? $this->debug = false : $this->debug = true;
        // message id
        $this->id = 1;
    }

    /**
     * Sets the notification state of the object. In this state, notifications are performed, instead of requests.
     *
     * @param boolean $notification
     */
    public function setRPCNotification($notification) {
        empty($notification) ?
        $this->notification = false
        :
        $this->notification = true;
    }

    /**
     * Performs a jsonRCP request and gets the results as an array
     *
     * @param string $method
     * @param array $params
     * @return array
     */
        public function __call($method,$params) {
        // check
        if (!is_scalar($method)) {
            throw new Exception('Method name has no scalar value');
        }

        // check
        if (is_array($params)) {
            // no keys
            $params = array_values($params);
        } else {
            throw new Exception('Params must be given as array');
        }

        // sets notification or request task
        if ($this->notification) {
            $currentId = NULL;
        } else {
            $currentId = $this->id;
        }

        // prepares the request
        $request = array(
            'method' => $method,
            'params' => $params,
            'id' => $currentId
        );
        $request = json_encode($request);
        $this->debug && $this->debug='***** Request *****'."\n".$request."\n".'***** End Of request *****'."\n\n";

        // performs the HTTP POST
        $ch = curl_init($this->url);
        // curl ssl options
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: application/json'));
        curl_setopt($ch, CURLOPT_POST, true);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
        $response = json_decode(curl_exec($ch),true);
        curl_close($ch);
        // debug output
        if ($this->debug) {
            echo nl2br($this->debug);
        }

        // final checks and return
        if (!$this->notification) {
            // check
            if ($response['id'] != $currentId) {
                throw new Exception('Incorrect response id (request id: '.$currentId.', response id: '.$response['id'].')');
            }
            if (!is_null($response['error'])) {
                throw new Exception('Request error: '.$response['error']);
            }
            return $response['result'];
        } else {
            return true;
        }
    }
}
?>

```

Please help me!!

**Tags:** bitcoind, json-rpc, connection

> **Comments:**
> **username_1**: WOW a ponzi /var/www/ponzi/htdocs/wallet/account.php just wow.....  
> **username_2**: may be server owner is just called Carlo?  

---

## 1 answers

### Answer by username_3 on 2016-04-21. Score: 1

The jsonRPC client does not handle errors from bitcoind well. [source](https://en.bitcoin.it/wiki/API_reference_(JSON-RPC)#PHP)

Instead it is recommended to use the easybitcoin php library, available on github [here](https://github.com/aceat64/EasyBitcoin-PHP). It's usage is simple and it outputs 404 and 500 errors properly.

```
require("easybitcoin.php");
$bitcoin = new Bitcoin("someusername", "somepassword");

$txid = $_GET["tx"];
$txinfo = $bitcoin->gettransaction($txid);
$amount = $txinfo["amount"]; 
echo $amount ? $amount : $bitcoin->error;

```


---

