Bitcoin Forum
November 02, 2024, 06:46:27 PM *
News: Latest Bitcoin Core release: 28.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: How to wait for confirmations blockchain.info API PHP  (Read 1280 times)
pulser (OP)
Newbie
*
Offline Offline

Activity: 13
Merit: 0


View Profile
July 14, 2014, 01:06:24 AM
Last edit: July 14, 2014, 05:41:20 PM by grue
 #1

Hello everybody

I am use blockchain in my shop for accept bitcoin but i need to wait for 2 block confirmation in php

Now i use a simple copy past in tutorial for test balance

Code:
$cc = @file_get_contents('https://blockchain.info/q/address/'.$address.'/?api_code='.$api_code);
$cc = $cc / 100000000;

if($do['balance'] > $cc) // if balance in blockchain change to 0
{
update
}
else // if deposit
{
                update
        }

Who to use like https://blockchain.info/q/address/'.$address.'/?api_code='.$api_code.'&confirmations=2 ?

Thanks you  Smiley
pulser (OP)
Newbie
*
Offline Offline

Activity: 13
Merit: 0


View Profile
July 18, 2014, 06:00:57 PM
 #2

Up  Smiley
arieq
Sr. Member
****
Offline Offline

Activity: 364
Merit: 256


View Profile
July 18, 2014, 09:34:46 PM
 #3

You may use $_GET['confirmations'], here is a good example,

Code:
if ($_GET['confirmations'] >= 4) {              // change 4 to whatever number you want
  //Add to the database

  //Delete from pending

  if ($result) {
        echo "*ok*";
  }
} else {
   //Waiting for confirmations
   //create a pending entry

   echo "Waiting for confirmations";
}

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!