<p>You don't have to use all the optional variables in your request link, specially when you have not set a second password, etc...</p>

<p>this suffice the request to send your transaction:</p>

<pre><code>$json_url = "https://blockchain.info/merchant/$guid/payment?password=$firstpassword&amp;to=$addressa&amp;amount=$amounta&amp;fee=$fee";
</code></pre>

<p>even if you remove "fee" variable, it would still work but you should consider 0.0001 miners fee that is there by default for minimum miners fee.</p>

<p>also you can get these values from the response:</p>

<pre><code>$json_feed = json_decode($json_data); 

$message = $json_feed-&gt;message; 
$txid = $json_feed-&gt;tx_hash; 
$notice = $json_feed-&gt;error; 
</code></pre>

CC BY-SA 3.0
2014-07-19T07:47:55.100Z
and what happens if I purposely put a wrong address?
rahulgarg12342
CC BY-SA 3.0
2014-07-19T07:52:04.363Z
it would send the btc to the wrong address...
Shayan
CC BY-SA 3.0
2014-07-19T07:52:34.003Z
you can add a "from=$addressb" to your request to indicate which address you are sending bitcoins from.
Shayan
CC BY-SA 3.0
2014-07-19T07:54:01.093Z
I meant an invalid address. And how do I print the message on screen with tx hash?
rahulgarg12342
CC BY-SA 3.0
2014-07-19T07:55:44.417Z
you would get the following fields in the response json:
$json_feed = json_decode($json_data);
$message = $json_feed->message;
$txid = $json_feed->tx_hash;
$notice = $json_feed->error;
Shayan
CC BY-SA 3.0
2014-07-19T08:00:56.413Z
But when I enter an address and run the php, I get no result.
rahulgarg12342
CC BY-SA 3.0
2014-07-19T10:21:46.953Z
@Shayanbahal better put the code of your comment into your answer otherwise its rly hard to read
Dennis Kriechel
CC BY-SA 3.0
2014-07-19T07:44:51.037Z
2014-07-19T22:45:34.797Z
2014-07-19T22:45:34.797Z
Shayan
<p>I am not very familiar with php but I just want to know how this works. I am trying to use the blockchain API to send some money for testing purposes but the transaction isn't taking place. My current code is this :-</p>

<pre><code>&lt;?

$guid="xxxxxxxx";
$main_password="xxxxxxxx";
$amount = "50000";
$to = "xxxxxxxx";


$json_url = "https://blockchain.info/merchant/$guid/payment?password=$main_password&amp;second_password=$second_password&amp;to=$address&amp;amount=$amount&amp;from=$from&amp;shared=$shared&amp;fee=$fee&amp;note=$note";

$json_data = file_get_contents($json_url);

$json_feed = json_decode($json_data);

$message = $json_feed-&gt;message;
$tx_hash = $json_feed-&gt;tx_hash;

?&gt;
</code></pre>

<p>Please tell me what is the error in my code and also how to print out the response on the screen.</p>

<transactions><api><blockchain.info>
How to send money using blockchain API?
rahulgarg12342
# How to send money using blockchain API?

(Asked by: username_0 on 2014-07-19)

I am not very familiar with php but I just want to know how this works. I am trying to use the blockchain API to send some money for testing purposes but the transaction isn't taking place. My current code is this :-

```
<?

$guid="xxxxxxxx";
$main_password="xxxxxxxx";
$amount = "50000";
$to = "xxxxxxxx";

$json_url = "https://blockchain.info/merchant/$guid/payment?password=$main_password&second_password=$second_password&to=$address&amount=$amount&from=$from&shared=$shared&fee=$fee&note=$note";

$json_data = file_get_contents($json_url);

$json_feed = json_decode($json_data);

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

?>

```

Please tell me what is the error in my code and also how to print out the response on the screen.

**Tags:** transactions, api, blockchain.info


---

## 1 answers

### Answer by username_1 on 2014-07-19. Score: 1

You don't have to use all the optional variables in your request link, specially when you have not set a second password, etc...

this suffice the request to send your transaction:

```
$json_url = "https://blockchain.info/merchant/$guid/payment?password=$firstpassword&to=$addressa&amount=$amounta&fee=$fee";

```

even if you remove "fee" variable, it would still work but you should consider 0.0001 miners fee that is there by default for minimum miners fee.

also you can get these values from the response:

```
$json_feed = json_decode($json_data); 

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

```

> **Comments:**
> **username_0**: and what happens if I purposely put a wrong address?  
> **username_1**: it would send the btc to the wrong address...  
> **username_1**: you can add a "from=$addressb" to your request to indicate which address you are sending bitcoins from.  
> **username_0**: I meant an invalid address. And how do I print the message on screen with tx hash?  
> **username_1**: you would get the following fields in the response json: $json_feed = json_decode($json_data); $message = $json_feed->message; $txid = $json_feed->tx_hash; $notice = $json_feed->error;  
> **username_0**: But when I enter an address and run the php, I get no result.  
> **username_2**: @Shayanbahal better put the code of your comment into your answer otherwise its rly hard to read  

---

