Bitcoin Forum
September 27, 2018, 11:07:59 PM *
News: ♦♦ New info! Bitcoin Core users absolutely must upgrade to previously-announced 0.16.3 [Torrent]. All Bitcoin users should temporarily trust confirmations slightly less. More info.
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: [Solved] Problem integrating daemon with PHP  (Read 542 times)
Shahrukh
Full Member
***
Offline Offline

Activity: 154
Merit: 100


View Profile WWW
January 11, 2014, 02:16:32 PM
 #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
1538089679
Hero Member
*
Offline Offline

Posts: 1538089679

View Profile Personal Message (Offline)

Ignore
1538089679
Reply with quote  #2

1538089679
Report to moderator
1538089679
Hero Member
*
Offline Offline

Posts: 1538089679

View Profile Personal Message (Offline)

Ignore
1538089679
Reply with quote  #2

1538089679
Report to moderator
Make a difference with your Ether.
Donate Ether for the greater good.
SPRING.WETRUST.IO
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1538089679
Hero Member
*
Offline Offline

Posts: 1538089679

View Profile Personal Message (Offline)

Ignore
1538089679
Reply with quote  #2

1538089679
Report to moderator
1538089679
Hero Member
*
Offline Offline

Posts: 1538089679

View Profile Personal Message (Offline)

Ignore
1538089679
Reply with quote  #2

1538089679
Report to moderator
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
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
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:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!