Bitcoin Forum

Bitcoin => Electrum => Topic started by: KocaEfe on February 23, 2017, 09:38:05 AM



Title: Electrum PHP Commands
Post by: KocaEfe on February 23, 2017, 09:38:05 AM
Hello everyone.. I want use, electrum daemon on my php pages without blockchain...

Electrum daemon and rpc port works fine... I use this electrum php lib; (My electrum version 2.6.4)
https://github.com/shaman/php-electrum-library

and my php page is this;

Code:
<?php
require_once'electrum.php';

$electrum = new Electrum('127.0.0.1'7777);

$response $electrum->getbalance();

echo 
"$response";
?>


But page is empty.. I see only white page. Please help me... Thanks.


Title: Re: Electrum PHP Commands
Post by: altcoinhosting2 on February 23, 2017, 09:46:03 AM
Hello everyone.. I want use, electrum daemon on my php pages without blockchain...

Electrum daemon and rpc port works fine... I use this electrum php lib; (My electrum version 2.6.4)
https://github.com/shaman/php-electrum-library

and my php page is this;

Code:
<?php
require_once'electrum.php';

$electrum = new Electrum('127.0.0.1'7777);

$response $electrum->getbalance();

echo 
"$response";
?>


But page is empty.. I see only white page. Please help me... Thanks.

I'm not familiar with the php-electrum-library, but your first order of business would be to:

1) create a testpage to see if php works fine... For example test.php
Code:
<?php
phpinfo
();
?>

If this page doesn't load properly, there is a problem with your lamp setup to begin with...

2) look at your server logs, the apache errorlogs are usually located in /var/log/apache2/error.log
Tail the errorlog and reload the page
Code:
tail -f /var/log/apache2/error.log
if you see errors appearing, they should point you towards what's wrong, if you have no clue => google is your friend

3) see what's in your variable, there are 2 ways of doing this:
Code:
<?php
require_once'electrum.php';

$electrum = new Electrum('127.0.0.1'7777);

$response $electrum->getbalance();

echo 
"<pre>";
print_r($response);
echo 
"</pre>";
?>


or

Code:
var_dump($response);

BTW, did you verify the prereqs?
Quote
electrum => 2.6.4
php => 5.6
php-curl
php-json


Title: Re: Electrum PHP Commands
Post by: KocaEfe on February 23, 2017, 09:51:46 AM
Thx buddy! fixed! :)) with php5-curl dependencines...


Title: Re: Electrum PHP Commands
Post by: altcoinhosting2 on February 23, 2017, 09:58:29 AM
Php is works fine..

But "nginx" my error.log is this;

Code:
2017/02/23 09:33:24 [error] 776#0: *5 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Call to undefined function curl_init() in /var/www/html/electrum.php on line 39" while reading response header from upstream, client: 192.168.2.203, server: your_server_ip, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "192.168.2.158"

I'm working on raspberry pi and connect with ssh... Please helpp  ??? :-\


Seems like
Code:
sudo apt-get install php5-curl

might do the trick ;) (at least, it might solve this issue... There is no guarantee that everything else will work, but you'll have to tackle one problem at a time)
(sollution = untested, i don't have a rPi running nginx, so i cannot test out the sollution)

don't forget to either restart nginx/php-fpm, or just to plain restart your box just to be sure...


Title: Re: Electrum PHP Commands
Post by: KocaEfe on February 23, 2017, 11:08:46 AM
How i generate new addresses? like bitcoind (generatenewaddress)...


Title: Re: Electrum PHP Commands
Post by: altcoinhosting2 on February 23, 2017, 02:43:31 PM
How i generate new addresses? like bitcoind (generatenewaddress)...

I'm not familiar with this library, nor with the electrum json-rpc api (i always use the core implementation's json-rpc api), but judging from this page:
http://docs.electrum.org/en/latest/merchant.html#create-a-signed-payment-request

I suppose it has to be something like this:
$response = $electrum->addrequest(1, "test");

This is completely untested (i don't have an electrum daemon running, nor an nginx stack, nor a rPi,... So i can only point towards what i think might be a sollution... It's up to you to test and debug).