2015-04-07 49 views
0

我試圖用PHP控制比特幣守護進程,但在嘗試連接到它時遇到問題。「無法打開流:權限被拒絕」使用JSON-RPC連接bitcoind PHP

我已經按照下列步驟操作:en.bitcoin(點)它/維基/ PHP_developer_intro

PHP代碼:

<?php 
require_once 'jsonRPCClient.php'; 
$bitcoin = new jsonRPCClient('http://user:[email protected]:8332/'); 
echo "<pre>\n"; 
print_r($bitcoin->getinfo()); 
echo "</pre>"; 
?> 

Bitcoind的conf:

rpcuser=user 
rpcpassword=password 
server=1 
daemon=1 
listen=1 

無功/日誌/ httpd/error_log:

[Tue Apr 06 15:47:15.403045 2015] [:error] [pid 2293] [client 10.0.0.34:50333] PHP Warning: fopen(http://[email protected]:8332/): failed to open stream: Permission denied in /var/www/html/jsonRPCClient.php on line 132 [Tue Apr 06 15:47:15.410993 2015] [:error] [pid 2293] [client 10.0.0.34:50333] PHP Fatal error: Uncaught exception 'Exception' with message 'Unable to connect to http://user:[email protected]:8332/ ' in /var/www/html/jsonRPCClient.php:140\nStack trace:\n#0 /var/www/html/bitcoin_get_info.php(15): jsonRPCClient->__call('getinfo', Array)\n#1 /var/www/html/bitcoin_get_info.php(15): jsonRPCClient->getinfo()\n#2 {main}\n thrown in /var/www/html/jsonRPCClient.php on line 1406

編輯:

$ bitcoin-cli getinfo 

做工精細,用PHP它沒有

回答

0

也許嘗試加入rpcallowip=127.0.0.1到您的配置,看看會發生什麼。

還要確保你的bitcoind.conf被實際使用,爲了測試這個,你可以使用testnet=1bitcoind.conf中設置守護進程爲testnet。重新啓動您的bitcoind服務器,然後執行bitcoin-cli getinfo以查看連接到哪個網絡。如果沒有反映變化,那麼bitcoind.conf文件可能位於另一個位置?

此外,請確保每次更改bitcoind.conf文件時都重新啓動bitcoind服務器。

相關問題