Accepting Donations: 1Lux3FWAAoNGHA7Hm1JNuBEuKjsTkezBf9
define( 'GUID', 'USER ID HERE');
define( 'FPASSWORD', 'FIRSTPASSWORD HERE');
define( 'SPASSWORD', 'SECOND PASSWORD HERE');
// Examples
//Get Balance
$BlockChain = new BlockChain;
//Will return json_encoded array
$Balance = $BlockChain->BlockChainAPI('balance');
echo "Encoded Balance: " . $Balance;
echo "
";
//Decode and get value
$Balance = json_decode($Balance);
echo "Decoded Balance: " . $Balance->balance;
echo "
";
//SendMany
//Array = 'Address' => 'BTCAmount converted to Satoshi'
$Addresses = Array('1Lux3FWAAoNGHA7Hm1JNuBEuKjsTkezBf9' => '10000000', '1Lux3FWAAoNGHA7Hm1JNuBEuKjsTkezBf9' => '10000000');
$SendMany = $BlockChain->BlockChainAPI('sendmany', $Addresses);
echo "Encoded send many return: " . $SendMany;
// Decode and get value
$SendMany = json_decode($SendMany);
echo "Message: " . $SendMany->message;
echo "Error: " . $SendMany->error;
//Generating a new address
$RandomLabel = "Get btc address";
$Address = $BlockChain->BlockChainAPI('new_address', array('label' => "$RandomLabel"));
//Return json_encoded Array
echo "Encoded Address: " . $Address;
// Decode Address
$Address = json_decode($Address);
echo "New Address: " . $Address->address;
echo "Label for Address: " . $Address->label;
Class BlockChain{
function BlockChainAPI($Param, $Param1 = null) {
// API settings
static $ch = null;
if (is_null($ch)) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; BlockChain PHP client;)');
}
curl_setopt($ch, CURLOPT_URL, "https://blockchain.info/merchant/" . GUID . "/$Param?password=" .FPASSWORD . "&second_password=" . SPASSWORD);
if($Param1){
$data = http_build_query($Param1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
}
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
$Return = curl_exec($ch);
return $res;
}
}
?>