Difference between revisions of "WalletBit/API"

From Bitcoin Wiki
Jump to: navigation, search
(Created page with "Three APIs are currently available: * Sent API * Getnewaddress API * Lookup API ===Sent to...")
 
Line 1: Line 1:
 
Three APIs are currently available:  
 
Three APIs are currently available:  
  
* [[WalletBit/API/Sent|Sent API]]  
+
* [[WalletBit/API/Send|Send API]]  
 
* [[WalletBit/API/Getnewaddress|Getnewaddress API]]  
 
* [[WalletBit/API/Getnewaddress|Getnewaddress API]]  
 
* [[WalletBit/API/Lookup|Lookup API]]
 
* [[WalletBit/API/Lookup|Lookup API]]
  
===Sent to Email or Bitcoin address===
+
===Send to Email or Bitcoin address===
  
 
<source lang="php">
 
<source lang="php">

Revision as of 15:08, 27 May 2012

Three APIs are currently available:

Send to Email or Bitcoin address

$fields = array(
  'merchant' => 'owner@example.com',
  'customer_email' => 'johnsmith@example.com',
  'address' => '',
  'amount' => 0.01000000,
  'details' => 'You got Bitcoins!'
);
$fields['encrypted'] = strtoupper(hash('sha256', $fields['merchant'] . ':' . $fields['customer_email'] . ':' . $fields['amount'] . ':' . 'API Key'));

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://walletbit.com/api');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, TRUE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, TRUE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_POST, count($fields));
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($fields));
$response = curl_exec($ch);
curl_close($ch);

if ($response == '1')
{

}

If 'customer_email' is not on WalletBit, it will try to send to the defined bitcoin address.

Generate new Bitcoin address

$fields = array(
  'merchant' => 'owner@example.com',
  'label' => 'TEST'
);
$fields['encrypted'] = strtoupper(hash('sha256', $fields['merchant'] . ':' . $fields['label'] . ':' . 'API Key'));

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://walletbit.com/api/getnewaddress');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, TRUE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, TRUE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_POST, count($fields));
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($fields));
$response = curl_exec($ch);
curl_close($ch);

If successful $response will contain your new bitcoin address, otherwise empty.

Lookup deposit to Bitcoin address

$fields = array(
  'merchant' => 'owner@example.com',
  'address' => '1BPeF1tGHQj1tHoyZkFps1QKCbnqdx2yHE'
);
$fields['encrypted'] = strtoupper(hash('sha256', $fields['merchant'] . ':' . $fields['address'] . ':' . 'API Key'));

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://walletbit.com/api/lookup/deposit');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, TRUE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, TRUE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_POST, count($fields));
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($fields));
$response = curl_exec($ch);
curl_close($ch);

If successful $response returns a json encoded array containing amount, confirmations, txid and timestamp of deposit to the provided Bitcoin address, otherwise empty.