Bitcoin Forum
July 03, 2024, 05:03:09 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Faucetbox Balance  (Read 319 times)
bitman29 (OP)
Member
**
Offline Offline

Activity: 83
Merit: 10


View Profile WWW
November 04, 2016, 10:47:33 AM
 #1

Hello I wanted to ask if anyone can help me, please.

I would like to show the balance of my XPM and BTC Faucet on another side - the variables are not so available.

my php is not good - please help!

sry my english is bad :-)

Curl is available
5ub_zer0
Full Member
***
Offline Offline

Activity: 238
Merit: 100



View Profile
November 04, 2016, 12:22:35 PM
 #2

If you have the credentials to the database you can try to create a file named i.ex balance.php and put the following in:


Code:
<?php
define 
'MYSQL_HOST',      'localhost' );
define 'MYSQL_USER',  'your-database-user' );
define 'MYSQL_PASSWORD',  'database-user-password' );
define 'MYSQL_DATABASE''faucetdatabasename' );

$db_link mysqli_connect (
                     
MYSQL_HOST
                     
MYSQL_USER
                     
MYSQL_PASSWORD
                     
MYSQL_DATABASE
                    
);
$sql "SELECT * FROM Faucetinabox_Settings LIMIT 3, 1";
 
$db_erg mysqli_query$db_link$sql );
if ( ! 
$db_erg )
{
  die(
'fail request: ' mysqli_error());
}
 
echo 
'<table border="1">';
while (
$zeile mysqli_fetch_array$db_ergMYSQL_ASSOC))
{
  echo 
"<tr>";
  echo 
"<th>"Bitcoin .   "</th>";
  echo 
"<td>"$zeile['name'] . "</td>";
  echo 
"<td>"$zeile['value'] . "</td>";
  echo 
"</tr>";
}
echo 
"</table>";
 
mysqli_free_result$db_erg );

?>


in the first 4 rows (define) put in your data
bitman29 (OP)
Member
**
Offline Offline

Activity: 83
Merit: 10


View Profile WWW
November 04, 2016, 12:51:57 PM
 #3

sry it not works.....i have not original faucetinabox script....i have also not faucetinabox mysql

i want a simple displaying

the balance: 55252525 Satoshi....that's all
i want a simple request from Faucetbox Api

i have tested with

$urlbase = "https://faucetbox.com/api/v1/balance";
$api_key ='--------your Site-Key---------';
$currency ='xpm';
$balance = file_get_contents_curl($urlbase.'/api_key='.$api_key.'&currency='.$currency);

echo $balance;

the get methods not working and from the post method i have no plans :-)
Curl is available

regards


5ub_zer0
Full Member
***
Offline Offline

Activity: 238
Merit: 100



View Profile
November 04, 2016, 01:08:50 PM
 #4

i have not original faucetinabox script.

ok sorry, than my suggestion doesnt work :-)

try this:

Code:
<?php
// Get cURL resource
$curl curl_init();
// Set some options - we are passing in a useragent too here
curl_setopt_array($curl, array(
    
CURLOPT_RETURNTRANSFER => 1,
    
CURLOPT_URL => 'https://faucetbox.com/api/v1/balance',
    
CURLOPT_USERAGENT => ' balance api test',
    
CURLOPT_POST => 1,
    
CURLOPT_POSTFIELDS => array(
        
api_key => '123456789',
currency => 'BTC'
    
)
));
// Send the request & save response to $resp
$resp curl_exec($curl);
// Close request to clear up some resources
curl_close($curl);
?>


<?php echo ($resp);?>
bitman29 (OP)
Member
**
Offline Offline

Activity: 83
Merit: 10


View Profile WWW
November 04, 2016, 01:33:22 PM
 #5

yeah it's work  Grin

response --> {"status":200,"balance":54511983,"balance_bitcoin":"0.54511983"}

is there still a possibility to output only the value of balance ...

example: --> 54511983 Satoshi
example: --> <?php echo $balance. 'Satoshi'; ?>

or similar
bitman29 (OP)
Member
**
Offline Offline

Activity: 83
Merit: 10


View Profile WWW
November 04, 2016, 03:56:11 PM
 #6

Thanks !!!!!

i have founded with json

very very thank you !!!!!!!!!  Shocked Grin
5ub_zer0
Full Member
***
Offline Offline

Activity: 238
Merit: 100



View Profile
November 04, 2016, 05:38:10 PM
Last edit: November 04, 2016, 08:14:03 PM by 5ub_zer0
 #7

Thanks !!!!!

i have founded with json

very very thank you !!!!!!!!!  Shocked Grin

Could you tell us how you did it ?

EDIT
OK have found a way to do it too  Cheesy

Code:
<?php
// Get cURL resource
$curl curl_init();
// Set some options
curl_setopt_array($curl, array(
    
CURLOPT_RETURNTRANSFER => 1,
    
CURLOPT_URL => 'https://faucetbox.com/api/v1/balance',
    
CURLOPT_HTTPHEADER, array('Content-Type: application/json'),
    
CURLOPT_POST => 1,
    
CURLOPT_POSTFIELDS => array(
        
api_key => '123456789',
currency => 'BTC'
    
)
));
// Send the request & save response to $resp
$resp curl_exec($curl);
// Close request to clear up some resources
curl_close($curl);

$json json_decode($resptrue);

// print_r($json);
?>


<p>Bitcoin Balance</p>
<?php echo $json['balance_bitcoin'];?>
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!