Bitcoin Forum
June 27, 2024, 10:26:58 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: [Solved] Problem integrating daemon with PHP  (Read 602 times)
Shahrukh (OP)
Full Member
***
Offline Offline

Activity: 154
Merit: 100


View Profile WWW
January 11, 2014, 02:16:32 PM
Last edit: January 12, 2014, 07:33:38 PM by Shahrukh
 #1

This is solved now, if you want you can have a look on https://bitcointalk.org/index.php?topic=412425.0


So I have installed daemon of bicoin litecoin and dogecoin on the same server all three of them are up and running but bitcoin daemon does not reply anything when I run bitcoind getinfo may be network issues or something like that. I have installed php on the same server and created a index.php file in /var/www/ folder


content of index.php file :
Code:
<?php
include_once('Bitcoin.php');
include_once(
'jsonRPCClient.php');
$dogecoin = new jsonRPCClient('http://user:pass@localhost:8332/');
print_r($dogecoin->getinfo());
?>


content of Bitcoin.php :
Code:
<?php
class Bitcoin (
// @var string
private $username;
// @var string
private @password;
// @var string
private $url;
// @var string
private $id;

public function 
__construct($url,$username,$password)
{
$this->url=$url;
$this->username $username;
$this->password $password;
$this->id 1;
}

public function 
__call($method,$params)
{
$params array_values($params);

$request json_encode(array(

'method' =>strtolower($method),
'params' => $params,
'id' => $this-> id));

$curl curl_init();
curl_setopt($curl,CURLOPT_RETURNTRANSFER1);
curl_setopt($curlCURLOPT_HTTPHEADER, Array("Content type:application/json"));
curl_setopt($curlCURLOPT_URL$this->url);
curl_setopt($curlCURLOPT_USERPWD$this->username.":".$this->password);
curl_setopt($curlCURLOPT_POSTTRUE);
curl_setopt($curlCURLOPT_POSTFIELDS$request);
$response curl_exec($curl);
curl_close($curl);

if(!
$resposne)
{
throw new 
Exception('Unable to connect to '.$this->url0);
}
$response json_decode($response,true);
}

then there are condition to throw different error upon different situation

}

I turned everyone down Sad Sorry for that
XBladeRunner
Newbie
*
Offline Offline

Activity: 34
Merit: 0


View Profile
January 11, 2014, 09:11:55 PM
 #2

Have you set the rpcport, rpcuser and rpcpassword in the .conf file? Also listen=1?
Shahrukh (OP)
Full Member
***
Offline Offline

Activity: 154
Merit: 100


View Profile WWW
January 11, 2014, 10:46:27 PM
 #3

Have you set the rpcport, rpcuser and rpcpassword in the .conf file? Also listen=1?

yes I did that but did not do listen=1 will do it right away and update if that works

I turned everyone down Sad Sorry for that
Shahrukh (OP)
Full Member
***
Offline Offline

Activity: 154
Merit: 100


View Profile WWW
January 12, 2014, 07:33:54 PM
 #4

Issue has been fixed

I turned everyone down Sad Sorry for that
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!