Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: pulser on February 27, 2014, 08:58:14 PM



Title: Php and daemon
Post by: pulser on February 27, 2014, 08:58:14 PM
Hi all i need to run litecoind and bitcoind with php in localhost (sorry for my little english  ;D)

Iam use this litecoin.conf

Code:
 server=1
daemon=1
rpcuser=litecoinrpc
rpcpassword=8u1EEMnoeBRTZu3ZYbYtNWSEQPp7QUPSW5z
rpcport=8332

And this class https://github.com/aceat64/EasyBitcoin-PHP/blob/master/easybitcoin.php (https://github.com/aceat64/EasyBitcoin-PHP/blob/master/easybitcoin.php)

And in my index i have

Code:
<?php
require_once('easybitcoin.php');
$bitcoin = new Bitcoin('litecoinrpc','8u1EEMnoeBRTZu3ZYbYtNWSEQPp7QUPSW5z','localhost','8332');
$bitcoin->getinfo();
?>

But not work and in my cmd.exe its ok

Code:
c:\Program Files\Litecoin\daemon>litecoind getinfo
{
    "version" : 80601,
    "protocolversion" : 70002,
    "walletversion" : 60000,
    "balance" : 0.00000000,
    "blocks" : 36119,
    "timeoffset" : -1,
    "connections" : 8,
    "proxy" : "",
    "difficulty" : 0.63768610,
    "testnet" : false,
    "keypoololdest" : 1388892634,
    "keypoolsize" : 101,
    "paytxfee" : 0.00000000,
    "mininput" : 0.00001000,
    "errors" : ""
}

Thanks for all  :)


Title: Re: Php and daemon
Post by: Abdussamad on February 27, 2014, 11:59:08 PM
Did you try echoing the last line:

echo $bitcoin->getinfo();


Title: Re: Php and daemon
Post by: cr1776 on February 28, 2014, 12:04:18 AM
Once you out this live, change the passwords since you posted them here.


Title: Re: Php and daemon
Post by: bitjoint on February 28, 2014, 12:32:32 AM
Once you out this live, change the passwords since you posted them here.

I hope that's not his real pass...  ;D


Title: Re: Php and daemon
Post by: cr1776 on February 28, 2014, 12:42:52 AM
Once you out this live, change the passwords since you posted them here.

I hope that's not his real pass...  ;D

I would hope not, but figured better to be safe.  ;-)


Title: Re: Php and daemon
Post by: metacoin on February 28, 2014, 04:04:35 AM
Try using http://jsonrpcphp.org/ instead

https://en.bitcoin.it/wiki/PHP_developer_intro

You'll have to write your own error handling to give adequate errors, though.


Title: Re: Php and daemon
Post by: Vortuarackne on February 28, 2014, 12:45:54 PM
...

Code:
<?php
require_once('easybitcoin.php');
$bitcoin = new Bitcoin('litecoinrpc','8u1EEMnoeBRTZu3ZYbYtNWSEQPp7QUPSW5z','localhost','8332');
$bitcoin->getinfo();
?>
...

This would produce no output. You would need to do something with it. Just to test, try something like this;

Code:
<?php
require_once('easybitcoin.php');
$bitcoin = new Bitcoin('litecoinrpc','8u1EEMnoeBRTZu3ZYbYtNWSEQPp7QUPSW5z','localhost','8332');
$getInfo $bitcoin->getinfo();
var_dump($getInfo);
?>


Title: Re: Php and daemon
Post by: aceat64 on March 03, 2014, 06:27:27 PM
Try using http://jsonrpcphp.org/ instead

https://en.bitcoin.it/wiki/PHP_developer_intro

You'll have to write your own error handling to give adequate errors, though.

FYI, JSON-RPC PHP is a terrible path to point new users/devs down. It uses fopen fopen() and will throw an exception saying "Unable to connect" if it receives a 404 or 500 error from bitcoind, instead of showing the error bitcoind was trying to give you.