TAiS46 (OP)
|
|
October 17, 2012, 07:43:18 PM |
|
Hey, I am trying to get the server status with PHP. Is the Server offline or online. <?php ini_set("display_errors", TRUE); include('./jsonRPCClient.php'); $bitcoin = new jsonRPCClient('http://bla:bla@111.111.111.111:8332/'); if ($bitcoin) { echo "online"; } else { echo "offline"; } ?>
dose not work, any idea?
|
|
|
|
Raoul Duke
aka psy
Legendary
Offline
Activity: 1358
Merit: 1002
|
|
October 17, 2012, 07:49:10 PM |
|
<?php ini_set("display_errors", TRUE); include('./jsonRPCClient.php'); $bitcoin = new jsonRPCClient('http://bla:bla@111.111.111.111:8332/'); $getinfo = $bitcoin->getinfo(); if ($getinfo != '') { echo "online"; } else { echo "offline"; } ?>
Try that. Or something alike. the new jsonRPCClient command only opens the connection, you need to ask something to the server to get a response.
|
|
|
|
TAiS46 (OP)
|
|
October 17, 2012, 07:53:40 PM |
|
already tried. Getting an 403 Forbidden error page.
|
|
|
|
|
BCB
CTG
VIP
Legendary
Offline
Activity: 1078
Merit: 1002
BCJ
|
|
October 17, 2012, 08:12:32 PM |
|
Are you making the call from a second box?
If credentials were wrong you'd be getting "Unable to connect to ..." with display errors.
Original code works.
|
|
|
|
Raoul Duke
aka psy
Legendary
Offline
Activity: 1358
Merit: 1002
|
|
October 17, 2012, 08:19:57 PM |
|
Are you making the call from a second box?
ah! rpcallowip=xxx.xxx.xxx.xxx good call That 403 would be returned if the flag was not set on bitcoin.conf
|
|
|
|
TAiS46 (OP)
|
|
October 17, 2012, 08:21:59 PM |
|
rpcallow etc is all set! if the server is online, $bitcoin->getinfo(); works.
I am trying now to get the status with fsockopen or other php commands hmmm
|
|
|
|
BCB
CTG
VIP
Legendary
Offline
Activity: 1078
Merit: 1002
BCJ
|
|
October 17, 2012, 08:26:27 PM |
|
if rpc allow was not set you'd be getting "failed to open stream: Connection refused"
|
|
|
|
TAiS46 (OP)
|
|
October 17, 2012, 08:30:03 PM |
|
Found a solution: <?php $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "http://**:**@111.111.111.111:8332/"); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $res = curl_exec($ch); curl_close($ch); if($res) { echo "onlin"; } else { echo "offline"; } ?>
|
|
|
|
BCB
CTG
VIP
Legendary
Offline
Activity: 1078
Merit: 1002
BCJ
|
|
October 17, 2012, 08:32:40 PM |
|
are you on shared boxes? sounds like a file or folder permission issue
|
|
|
|
TAiS46 (OP)
|
|
October 17, 2012, 08:35:09 PM |
|
no, everything dose work, dose someone try out to get the offline status? i dont think so. using now the curl methode
|
|
|
|
kjj
Legendary
Offline
Activity: 1302
Merit: 1026
|
|
October 21, 2012, 03:47:38 PM |
|
How about a try/catch block? <?php ini_set("display_errors", TRUE); include('./jsonRPCClient.php');
try{ $bitcoin = new jsonRPCClient('http://bla:bla@111.111.111.111:8332/'); $getinfo = $bitcoin->getinfo(); echo "online"; }catch(Exception $e){ echo "offline: $e"; } ?>
|
17Np17BSrpnHCZ2pgtiMNnhjnsWJ2TMqq8 I routinely ignore posters with paid advertising in their sigs. You should too.
|
|
|
|