Skip to content

PHP Library for our API Easily integrate our API with this PHP library

Before we continue, we'd like to say thanks to Faucetbox.com for making their PHP library. Our PHP library is an edited version of theirs. We chose to do this since our main API is 100% compatible with Faucetbox.com's API.

Requirements What do I need to run it?

The library requires the following to operate correctly:

  • PHP 5
  • cURL PHP module (optional)

The above things are available with most shared hosting providers.

The code The main reason you're here

Current Version: v1.0

Download

Basic usage example How to quickly get started

The library provides 2 classes: FaucetHub and FaucetBOX. The FaucetHub class is the main class you will be using to integrate your application. The FaucetBOX class is a compatibility class which allows you to simply replace the traditional Faucetbox.com PHP library with our one without needing to edit any other code in your script, and functionality will work the same.

If you use a custom script make sure you respond correctly to status code 456 when making a payout. More information on this on the Migration guide.

# Credits to FaucetBOX.com for the original code example
$api_key = "YOUR_API_KEY";
$currency = "BTC"; # or LTC or any other supported by FaucetHub
$faucethub = new FaucetHub($api_key, $currency);

# To send 500 satoshi to address
$result = $faucethub->send("1asdbitcoinaddressheredsa", 500);

if($result["success"] === true) {   # you can check if it was successful
    echo $result["html"];           # there's example html ready for you
} else {                            # something went wrong :(
    log_error($result["response"]); # you can log whole response from server
    echo $result["html"];           # and display error message to user
}