Bitcoin Forum
September 25, 2024, 05:22:09 PM *
News: Latest Bitcoin Core release: 27.1 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: PHP developer intro on Windows server errors and setup  (Read 6587 times)
www.al3ashi8.com (OP)
Full Member
***
Offline Offline

Activity: 224
Merit: 100


View Profile
October 26, 2013, 09:32:39 PM
 #1

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:
<?php
require_once 'jsonRPCClient.php';
$myExample = new jsonRPCClient('http://user:password@localhost:8332');
$myExample->getbalance();
?>
Am I doing anything wrong?
fbueller
Sr. Member
****
Offline Offline

Activity: 412
Merit: 287


View Profile
October 26, 2013, 10:31:43 PM
 #2

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());

Bitwasp Developer.
DualSignal
Newbie
*
Offline Offline

Activity: 28
Merit: 0


View Profile
November 13, 2013, 08:47:53 AM
 #3

That doesn't look to be the latest version of bitcoin. Keep up to date with the regular releases.
Btc-Go
Newbie
*
Offline Offline

Activity: 14
Merit: 0


View Profile WWW
November 13, 2013, 09:02:03 AM
 #4

Make sure you run bitcoin-qt with -server option, so that you can actually connect to RPC.
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!