Bitcoin Forum
May 22, 2024, 12:11:57 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Warning: One or more bitcointalk.org users have reported that they strongly believe that the creator of this topic is a scammer. (Login to see the detailed trust ratings.) While the bitcointalk.org administration does not verify such claims, you should proceed with extreme caution.
Pages: [1]
  Print  
Author Topic: blockchain.info api multi send HELP  (Read 4096 times)
likl3sfuhjh (OP)
Sr. Member
****
Offline Offline

Activity: 335
Merit: 250


View Profile
April 25, 2013, 07:27:07 PM
 #1


This code segment is from http://blockchain.info/api/blockchain_wallet_api
How do i execute this? what do i need to install, do i need to link to a json library or something. I need a step thru process here.  Thanks

Code:
<?

$guid="GUID_HERE";
$firstpassword="PASSWORD_HERE";
$secondpassword="PASSWORD_HERE";
$amounta = "10000000";
$amountb = "400000";
$addressa = "1A8JiWcwvpY7tAopUkSnGuEYHmzGYfZPiq";
$addressb = "1ExD2je6UNxL5oSu6iPUhn9Ta7UrN8bjBy";
$recipients = urlencode('{
                  "'.$addressa.'": '.$amounta.',
                  "'.$addressb.'": '.$amountb.'
               }');

$json_url = "http://blockchain.info/merchant/$guid/sendmany?password=$firstpassword&second_password=$secondpassword&recipients=$recipients";

$json_data = file_get_contents($json_url);

$json_feed = json_decode($json_data);

$message = $json_feed->message;
$txid = $json_feed->tx_hash;

?>

Where do I get free bitcoins?
www.bitcoinforest.com - Bitcoin faucet and survey site. Get .001 bitcoins for each survey, and .00001 for each captcha.
scintill
Sr. Member
****
Offline Offline

Activity: 448
Merit: 254


View Profile WWW
April 26, 2013, 10:38:51 PM
 #2

I think it would be more efficient for you to answer, what errors are you experiencing?

The json module seems to be enabled by default in recent PHP versions.  The only other dependency is on the http file wrapper being enabled, in the file_get_contents call.  What is the output of var_dump(stream_get_wrappers()) ?

1SCiN5kqkAbxxwesKMsH9GvyWnWP5YK2W | donations
Petr1fied
Hero Member
*****
Offline Offline

Activity: 630
Merit: 502


View Profile
April 27, 2013, 05:36:42 PM
Last edit: April 28, 2013, 03:17:03 AM by Petr1fied
 #3

Here's a practical example with php/MySQL.

Lets say for the sake of argument you have a MySQL database table like this:
Code:
CREATE TABLE `bitcoin_payments` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `bitcoin_address` varchar(34) NOT NULL,
  `payment_in_satoshi` bigint(20) unsigned NOT NULL DEFAULT '0',
  `transaction_hash` varchar(64) NOT NULL,
  PRIMARY KEY (`id`)
);

And in this table you have a list of payments to be made. If the payment has already been made then the transaction_hash field contains the transaction hash the payment was made with, otherwise it's empty.

Code:
<?php

$guid
="GUID_HERE";
$firstpassword="PASSWORD_HERE";
$secondpassword="PASSWORD_HERE";

// Your MySQL database login credentials here
$host="localhost"// MySQL host
$user=""// MySQL user
$pass=""// MySQL password for user above
$db=""// MySQL database to use

mysql_select_db($dbmysql_connect($host$user$pass));

$result=mysql_query("SELECT `id`, `bitcoin_address`, `payment_in_satoshi` FROM `bitcoin_payments` WHERE `transaction_hash`='' ORDER BY `id` ASC");
$recipient_list=array();
$new_paid_ids="";
if(
mysql_num_rows($result)>0)
{
    while(
$row=mysql_fetch_assoc($result))
    {
        
$new_paid_ids.=$row["id"].",";
        
$recipient_list[$row["bitcoin_address"]]=$row["payment_in_satoshi"];
    }
    
$new_paid_ids=trim($new_paid_ids",");
}
if(
count($recipient_list)>0)
{
    
$recipients=urlencode(json_encode($recipient_list));
    
$json_url "http://blockchain.info/merchant/$guid/sendmany?password=$firstpassword&second_password=$secondpassword&recipients=$recipients";
    
$json_data file_get_contents($json_url);
    if(
$http_response_header[0]=="HTTP/1.1 200 OK")
    {
        
$json_feed json_decode($json_data);
        
$error $json_feed->error;
        if(
is_null($error))
        {
            
$message $json_feed->message;
            
$txid $json_feed->tx_hash;
            
mysql_query("UPDATE `bitcoin_address` SET `transaction_hash`='".mysql_real_escape_string($txid)."' WHERE `id` IN(".$new_paid_ids.")");
            echo 
$message." - <a href='https://blockchain.info/tx/".$txid."'>".$txid."</a>";
        }
        else
            echo 
$error;
    }
    else
        echo 
"bitchain.info returned the following http error:<br /><br />".$http_response_header[0];
}

?>

Please note the above is not tested but it should work in theory. Wink
likl3sfuhjh (OP)
Sr. Member
****
Offline Offline

Activity: 335
Merit: 250


View Profile
April 28, 2013, 02:15:53 AM
 #4

how do you send the data

Where do I get free bitcoins?
www.bitcoinforest.com - Bitcoin faucet and survey site. Get .001 bitcoins for each survey, and .00001 for each captcha.
Petr1fied
Hero Member
*****
Offline Offline

Activity: 630
Merit: 502


View Profile
April 28, 2013, 03:10:35 AM
 #5

The data is sent in the file_get_contents() line. (Line 31 in the example above). It's the equivalent of you opening the url stored in the variable $json_url in your Web browser. Assuming you get a 200 response and no error is returned, the funds will have been sent at this point.
likl3sfuhjh (OP)
Sr. Member
****
Offline Offline

Activity: 335
Merit: 250


View Profile
April 28, 2013, 03:14:48 AM
 #6

ok thought so thanks

Where do I get free bitcoins?
www.bitcoinforest.com - Bitcoin faucet and survey site. Get .001 bitcoins for each survey, and .00001 for each captcha.
Petr1fied
Hero Member
*****
Offline Offline

Activity: 630
Merit: 502


View Profile
April 28, 2013, 03:18:23 AM
 #7

No problem.  Wink
likl3sfuhjh (OP)
Sr. Member
****
Offline Offline

Activity: 335
Merit: 250


View Profile
April 28, 2013, 03:45:43 AM
Last edit: April 28, 2013, 05:16:50 AM by likl3sfuhjh
 #8

removed

Where do I get free bitcoins?
www.bitcoinforest.com - Bitcoin faucet and survey site. Get .001 bitcoins for each survey, and .00001 for each captcha.
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!