Title: Blockchain API sendmany PLS HELP! Post by: dhavin on November 07, 2014, 04:12:52 AM 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` ( 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 Please note the above is not tested but it should work in theory. ;) So this old thread is the closest I can find to a working PHP example of sendmany using Blockchain's API. I cannot get it to work, it's driving me completely batty. I've got the right passwords and guid and I'm using the code posted above and I get back "Unknown Error" from the API. Can anyone take a moment to look at the code, maybe you can see something I missed? Very much appreciated! Title: Re: Blockchain API sendmany PLS HELP! Post by: TheBeardedOne on November 07, 2014, 11:46:03 AM First I believe that the mysql statements that you are using are deprecated.
http://php.net/manual/en/function.mysql-select-db.php You should look into PDO's. As for what you are doing with the array, if you are already looping through it you may as well build a JSON string right off the bat - i mean I wouldn't do it personally but it gets the job done and there is really nothing wrong with it. Using the sendmany example here: https://blockchain.info/api/blockchain_wallet_api Then just call URL encode. One thing that comes to the top of my head, this being from experience using qt, do you have an address listed twice in the send many data? I know that qt does not allow this when using rpc. Title: Re: Blockchain API sendmany PLS HELP! Post by: dhavin on November 07, 2014, 01:10:38 PM The urlencoded output of the array is: (i just manually threw some spaces in there to improve readability)
%7B%22 1CagL2pgL73cs4LBCq82RYUunXJUw4yXBz %22%3A%22 5500 %22%2C%22 19rbySNBMmYvhmUgpBLGbqHXzJDBotchSy %22%3A%22 5500 %22%7D So it's two different addresses. Encoding looks correct.. 7B = { 3A = : 2C = , and 7D = } Any other thoughts? Title: Re: Blockchain API sendmany PLS HELP! Post by: TheBeardedOne on November 07, 2014, 03:19:53 PM Remove the quotation marks " " around the amount sent. Only the address should be within their own "".
EDIT: Think you need to cast the $row["payment_in_satoshi"] to int, intval() i believe is the function. Title: Re: Blockchain API sendmany PLS HELP! Post by: dhavin on November 07, 2014, 04:27:42 PM Remove the quotation marks " " around the amount sent. Only the address should be within their own "". EDIT: Think you need to cast the $row["payment_in_satoshi"] to int, intval() i believe is the function. The quotations didn't matter, intval() nailed it. Thank you! |