Author

Topic: PHP developer intro on Windows server errors and setup (Read 6597 times)

newbie
Activity: 14
Merit: 0
Make sure you run bitcoin-qt with -server option, so that you can actually connect to RPC.
newbie
Activity: 28
Merit: 0
That doesn't look to be the latest version of bitcoin. Keep up to date with the regular releases.
sr. member
Activity: 412
Merit: 287
You might get more information about the error if you alter a line down the bottom of the jsonrpcclient.php

Code:
if (!is_null($response['error'])) {
    throw new Exception('Request error: '.$response['error']);
}

with this:

Code:
if (!is_null($response['error'])) {
    return $response['error'];
}

Then do:
var_dump($myExample->getbalance());
full member
Activity: 224
Merit: 100
I'm trying to get the PHP developer intro https://en.bitcoin.it/wiki/PHP_developer_intro on a windows machine and keep getting errors.
Code:
Warning: fopen(http://...@localhost:8332) [function.fopen]: failed to open stream: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. in C:\xampp\htdocs\bitcoin-app\jsonRPCClient.php on line 132

Fatal error: Uncaught exception 'Exception' with message 'Unable to connect to http://user:password@localhost:8332' in C:\xampp\htdocs\bitcoin-app\jsonRPCClient.php:140 Stack trace: #0 [internal function]: jsonRPCClient->__call('getbalance', Array) #1 C:\xampp\htdocs\bitcoin-app\hello.php(4): jsonRPCClient->getbalance() #2 {main} thrown in C:\xampp\htdocs\bitcoin-app\jsonRPCClient.php on line 140
Steps I've taken:

1) downloaded portable bitcoin client from http://sourceforge.net/projects/bitcoin/files/Bitcoin/bitcoin-0.6.3/bitcoin-0.6.3-win32.zip/download
2) imported updated blk0001.dat and blk0002.dat from another pc and let the bitcoin client verify the blockchain. Client is now up to date and running on windows machine.
3) sent 0.1btc to the bitcoin address
4) made a C:\Users\dev\AppData\Roaming\Bitcoin\bitcoin.conf file containing:
Code:
server=1
rpcuser=user
rpcpassword=password
rpctimeout=90
rpcallowip=127.0.0.1
rpcport=8332
5) added jsonRPCClient.php in the www folder web accessible
6) index.php code:
Code:
require_once 'jsonRPCClient.php';
$myExample = new jsonRPCClient('http://user:password@localhost:8332');
$myExample->getbalance();
?>
Am I doing anything wrong?
Jump to: