Paytoshi PHP Library
, (*1)
PHP Library for Paytoshi's API., (*2)
Requirements
- PHP >= 5.3
- PHP cURL extension (recommended) OR
-
allow_fopen_url enabled in your PHP config.
Installation
The recommended way to install Paytoshi PHP Library is through composer., (*3)
composer.phar require looptribe/paytoshi-library-php
Usage
Paytoshi PHP Library uses the Buzz library., (*4)
Create the API wrapper object
Using FileGetContents
``` php
<?php, (*5)
$browser = new \Buzz\Browser();
$paytoshi = new \Looptribe\Paytoshi\Api\PaytoshiApi($browser, 'http://paytoshi.org/api/v1/');, (*6)
#### Using cUrl
``` php
<?php
$browser = new \Buzz\Browser(new \Buzz\Client\Curl());
$paytoshi = new Looptribe\Paytoshi\Api\PaytoshiApi($browser, 'http://paytoshi.org/api/v1/');
Setup the client
If you wish you can set a timeout on the requests (default 5 seconds):
``` php
<?php, (*7)
// Set 10 seconds of timeout
$browser->getClient()->setTimeout(10);, (*8)
### Faucet API
#### Create a new faucet payout
``` php
<?php
// Create the $paytoshi object as explained in the previous section
...
// Create a new payout
$result = $paytoshi->send(
'a8p9uevhfgx7ewt1kf09v2n3kfhzkeyxi8ywcehfqnl9is30gq', //Faucet Api key
'1EhNaUFaVW99in6drLeD8ygrLicAcf8rAc', //Bitcoin address
100, //Amount
'127.0.0.1' //Recipient ip
);
// Create a referral payout
$result = $paytoshi->send(
'a8p9uevhfgx7ewt1kf09v2n3kfhzkeyxi8ywcehfqnl9is30gq', //Faucet Api key
'18aWoXRJRTfK8ZdxH9Y8qW3Q3AKPqra2DlyO', //Bitcoin address
100, //Amount
'127.0.0.1', //Recipient ip
true //Referral flag
);
Check balance
``` php
// Check balance
$result = $paytoshi->getBalance(
'a8p9uevhfgx7ewt1kf09v2n3kfhzkeyxi8ywcehfqnl9is30gq' //Faucet Api key
);, (*9)
// Your balance in satoshi
$balance = $result->getAvailableBalance();
```, (*10)
License
Paytoshi PHP Library is BSD licensed., (*11)