Bitcoin Forum
May 24, 2024, 09:05:36 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: send payment via php?  (Read 689 times)
velacreations (OP)
Sr. Member
****
Offline Offline

Activity: 476
Merit: 250


View Profile
January 31, 2013, 06:50:57 PM
 #1

Does anyone know how to send a payment using php and the Blockchain.info api?

Here's the api link: http://blockchain.info/api/json_rpc_api

In there it gives a method for doing so:
Quote
    Method: sendtoaddress
    Parameters: (String bitcoinAddress, long amount)
    Description: amount is a real and is rounded to 8 decimal places. Returns the transaction hash if successful. .
    Returns: String
    Second Password Required

But it says Second Password Required.  So how do I pass my second password?

Higher on the page, it says this:
Quote
Security
This api is currently incompatible with two factor authentication and it must therefore be disabled.

So, how do I send a payment?

piuk
Hero Member
*****
expert
Offline Offline

Activity: 910
Merit: 1005



View Profile WWW
January 31, 2013, 07:18:57 PM
 #2

Does anyone know how to send a payment using php and the Blockchain.info api?

Here's the api link: http://blockchain.info/api/json_rpc_api

In there it gives a method for doing so:
Quote
    Method: sendtoaddress
    Parameters: (String bitcoinAddress, long amount)
    Description: amount is a real and is rounded to 8 decimal places. Returns the transaction hash if successful. .
    Returns: String
    Second Password Required

But it says Second Password Required.  So how do I pass my second password?

The second password is provided by first calling the walletpassphrase method.

This api is currently incompatible with two factor authentication and it must therefore be disabled.

So, how do I send a payment?

Two factor authentication must be disabled in Account Settings.

------

Assuming you only want to send you would be better off using http://blockchain.info/api/blockchain_wallet_api. Very rough example

<?php

$wallet_identifier = 'abf66471-fe0a-6820-8977-55d7e8c1f6b2';

$address = 'Your Bitcoin address';

$password = 'Your Password';

$second_password = 'Your Second password'; //Only if double encryption is enabled in account settings

$amount = 100000000; //1 BTC in Satoshi

$response = file_get_contents("https://blockchain.info/merchant/$wallet_identifier/payment?password=$password!&second_password=$second_password&to=$address&amount=$amount");

//Check response for errors

php?>

velacreations (OP)
Sr. Member
****
Offline Offline

Activity: 476
Merit: 250


View Profile
January 31, 2013, 07:41:35 PM
 #3

yeah, I was just reading about that method on the Wallet API.  Thanks for that.

Is there any good code snippets around for handling errors?  I'm basically seeing if response is empty or not an array, but I imagine there is a better method.

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!