<p>As of January 2016 Blockchain.info made changes to the wallet API service that now requires you to run a local nodeJS service to handle the calls. This will require you to have root access to your webserver so you will need to use a VPS instead of a basic shared web host. </p>

<p>Also I don't recommend hand-coding the JSON yourself when using sendmany. Instead create an array and then use the json_encode function.</p>

<pre><code>$array = array(
    "1someAddress" =&gt; 20000,
    "1someAddress2" =&gt; 150000,
    "1someAddress3" =&gt; 314159
); 
$addresses = json_encode($array);
</code></pre>

<p>You're not the only one that has hard time with the new version of their API. If you still need some help check out these resources. </p>

<p><a href="https://www.youtube.com/watch?v=X8jsaf4sEgs" rel="nofollow" title="Video Tutorial: How to Setup Blockchains New Wallet API Service">https://www.youtube.com/watch?v=X8jsaf4sEgs</a><br>
<a href="http://btcthreads.com/how-to-setup-blockchain-wallet-service/" rel="nofollow">http://btcthreads.com/how-to-setup-blockchain-wallet-service/</a> </p>

<p>I started a PHP library for communicating with the nodeJS service, (still needs work, some functions are missing) <a href="https://github.com/coinables/blockchain-wallet-APIv2-PHP-Library" rel="nofollow">https://github.com/coinables/blockchain-wallet-APIv2-PHP-Library</a></p>

CC BY-SA 3.0
2016-03-24T12:48:05.690Z
2016-03-24T12:48:05.690Z
m1xolyd1an
<p>I'm currently using v2 of Blockchain.info's API and am wanting to utilise "Send Many Transaction" and am having some issues.</p>

<p>I have 1 wallet with many addresses, I am trying to send 2 transactions within 1 payment, their API documentation is still from v1 and is missing the '&amp;from' from their api example, and have spent more time than I'd like to admit to get this working.</p>

<p>this is from there website:</p>

<pre><code>http://localhost:3000/merchant/$guid/sendmany?password=$main_password&amp;second_password=$second_password&amp;recipients=$recipients&amp;fee=$fee

$main_password Your Main Blockchain wallet password
$second_password Your second Blockchain Wallet password if double encryption  is enabled.
$recipients Is a JSON Object using Bitcoin Addresses as keys and the amounts to send as values (See below).
$from Send from a specific Bitcoin Address (Optional)
$fee Transaction fee value in satoshi (Must be greater than default fee) (Optional)
$note A public note to include with the transaction -- can only be attached to transactions where all outputs are greater than 0.005 BTC.(Optional)
</code></pre>

<p>The result I get is:</p>

<p>failed to open stream:HTTP request failed!</p>

<p>Fatal error:Maximum execution time of 120 seconds exceeded</p>

<p>I now the url is wrong but can anyone please help advise me what it is specifically.</p>

<p>So far this is what I have</p>

<pre><code>// Sending addresses 
$Address1 = 'Address1';
$Address2 = 'Address2';

//Amount coming from
$From = 'Address3';

//Amounts being sent in satoshi
$Amount1 = 100000;  // 0.001 of a btc
$Amount2 = 100000;  

$recipients = urlencode(' {
    "'.$Address1.'": '.$Amount1.',  
    "'.$Address2.'": '.$Amount2.'
}');

$Guid = 'MY_GUID';      
$Password = 'MY_PASSWORD';                              

$url = 'http://localhost:3000/merchant/'.$Guid.'/sendmany?password='.$Password.'&amp;from='.$From.'&amp;recipients='.$recipients.''; 
// I've also tried to remove $data and put '&amp;api_code=MY_API_CODE' after
// $recipients as this also works for other api calls for v2

$data = array('api_code' =&gt; 'MY_API_CODE');

$result = sendAmounts($url, $data);

function sendAmounts($url, $data) { 
$options = array(
    'http' =&gt; array(
        'header'  =&gt; "Content-type: application/x-www-form-urlencoded\r\n",
        'method'  =&gt; 'POST',  // Also tried GET
        'content' =&gt; http_build_query($data),
    ),
);
$context  = stream_context_create($options);
$result = file_get_contents($url, false, $context);

return $result;
}
</code></pre>

<p>Thank you in advance.</p>

CC BY-SA 3.0
2016-03-24T12:24:26.760Z
Did you already set up your local nodejs service?
m1xolyd1an
CC BY-SA 3.0
2016-03-24T23:16:27.253Z
@m1xolyd1an - yes I have set up nodejs, I can get balances, send a single payment etc.. just send many transactions is giving me grief
Dougio
<transactions><blockchain><api><php>
Blockchain.info send may transactions API v2
Dougio
# Blockchain.info send may transactions API v2

(Asked by: username_0 on 2016-03-24)

I'm currently using v2 of Blockchain.info's API and am wanting to utilise "Send Many Transaction" and am having some issues.

I have 1 wallet with many addresses, I am trying to send 2 transactions within 1 payment, their API documentation is still from v1 and is missing the '&from' from their api example, and have spent more time than I'd like to admit to get this working.

this is from there website:

```
http://localhost:3000/merchant/$guid/sendmany?password=$main_password&second_password=$second_password&recipients=$recipients&fee=$fee

$main_password Your Main Blockchain wallet password
$second_password Your second Blockchain Wallet password if double encryption  is enabled.
$recipients Is a JSON Object using Bitcoin Addresses as keys and the amounts to send as values (See below).
$from Send from a specific Bitcoin Address (Optional)
$fee Transaction fee value in satoshi (Must be greater than default fee) (Optional)
$note A public note to include with the transaction -- can only be attached to transactions where all outputs are greater than 0.005 BTC.(Optional)

```

The result I get is:

failed to open stream:HTTP request failed!

Fatal error:Maximum execution time of 120 seconds exceeded

I now the url is wrong but can anyone please help advise me what it is specifically.

So far this is what I have

```
// Sending addresses 
$Address1 = 'Address1';
$Address2 = 'Address2';

//Amount coming from
$From = 'Address3';

//Amounts being sent in satoshi
$Amount1 = 100000;  // 0.001 of a btc
$Amount2 = 100000;  

$recipients = urlencode(' {
    "'.$Address1.'": '.$Amount1.',  
    "'.$Address2.'": '.$Amount2.'
}');

$Guid = 'MY_GUID';      
$Password = 'MY_PASSWORD';                              

$url = 'http://localhost:3000/merchant/'.$Guid.'/sendmany?password='.$Password.'&from='.$From.'&recipients='.$recipients.''; 
// I've also tried to remove $data and put '&api_code=MY_API_CODE' after
// $recipients as this also works for other api calls for v2

$data = array('api_code' => 'MY_API_CODE');

$result = sendAmounts($url, $data);

function sendAmounts($url, $data) { 
$options = array(
    'http' => array(
        'header'  => "Content-type: application/x-www-form-urlencoded\r\n",
        'method'  => 'POST',  // Also tried GET
        'content' => http_build_query($data),
    ),
);
$context  = stream_context_create($options);
$result = file_get_contents($url, false, $context);

return $result;
}

```

Thank you in advance.

**Tags:** transactions, blockchain, api, php

> **Comments:**
> **username_1**: Did you already set up your local nodejs service?  
> **username_0**: @username_1 - yes I have set up nodejs, I can get balances, send a single payment etc.. just send many transactions is giving me grief  

---

## 1 answers

### Answer by username_1 on 2016-03-24. Score: 0 | Accepted answer

As of January 2016 Blockchain.info made changes to the wallet API service that now requires you to run a local nodeJS service to handle the calls. This will require you to have root access to your webserver so you will need to use a VPS instead of a basic shared web host.

Also I don't recommend hand-coding the JSON yourself when using sendmany. Instead create an array and then use the json\_encode function.

```
$array = array(
    "1someAddress" => 20000,
    "1someAddress2" => 150000,
    "1someAddress3" => 314159
); 
$addresses = json_encode($array);

```

You're not the only one that has hard time with the new version of their API. If you still need some help check out these resources.

[https://www.youtube.com/watch?v=X8jsaf4sEgs](https://www.youtube.com/watch?v=X8jsaf4sEgs "Video Tutorial: How to Setup Blockchains New Wallet API Service")  
<http://btcthreads.com/how-to-setup-blockchain-wallet-service/>

I started a PHP library for communicating with the nodeJS service, (still needs work, some functions are missing) <https://github.com/coinables/blockchain-wallet-APIv2-PHP-Library>


---

