Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: klestor on February 18, 2013, 11:52:28 PM



Title: Help with Blockchain API sendmany
Post by: klestor on February 18, 2013, 11:52:28 PM
Hey,

Using PHP I've had success using the "payment" method and now trying to use "sendmany".

This is my request I'm using.
https://blockchain.info/merchant/$guid/sendmany?password=$pass&second_password=$pass2&recipients={"add1":"65400","add2":"65400"}&anonymous=false&fee=50000

And I keep getting this error:
{"error":"java.lang.String cannot be cast to java.lang.Long"}

Have I formatted the recipients incorrectly?
I've tried removing the "quotes" from the amounts but get the unknown error

Here is the documentation:
https://blockchain.info/api/blockchain_wallet_api

Any ideas?



Title: Re: Help with Blockchain API sendmany
Post by: Zeilap on February 19, 2013, 12:14:10 AM
Hey,

Using PHP I've had success using the "payment" method and now trying to use "sendmany".

This is my request I'm using.
https://blockchain.info/merchant/$guid/sendmany?password=$pass&second_password=$pass2&recipients={"add1":"65400","add2":"65400"}&anonymous=false&fee=50000

And I keep getting this error:
{"error":"java.lang.String cannot be cast to java.lang.Long"}

Have I formatted the recipients incorrectly?
I've tried removing the "quotes" from the amounts but get the unknown error

Here is the documentation:
https://blockchain.info/api/blockchain_wallet_api

Any ideas?


Try removing the quotes from the numbers in the recipients?


Title: Re: Help with Blockchain API sendmany
Post by: klestor on February 19, 2013, 12:19:25 AM
yep, I've tried removing the quotes from the numbers and get {"error":"Unknown Error"}


Title: Re: Help with Blockchain API sendmany
Post by: piuk on February 19, 2013, 12:28:36 AM
yep, I've tried removing the quotes from the numbers and get {"error":"Unknown Error"}

Are you URL encoding the recipients JSON?


Title: Re: Help with Blockchain API sendmany
Post by: klestor on February 19, 2013, 12:38:03 AM
Quote
Are you URL encoding the recipients JSON?

I think  ??? I'm doing this correctly, here is my code:

Code:
    foreach($payments as $addr){
        $add = $addr['add'];
        $addresses[add] = $addr['amount'] * 100000000;
    }
    $recipients = json_encode($addresses);

    $url = "https://blockchain.info/merchant/".$guid."/sendmany?password=".$pass."&second_password=".$pass2."&recipients=".$recipients."&anonymous=false&fee=50000"
    $response = file_get_contents($url);



Title: Re: Help with Blockchain API sendmany
Post by: Zeilap on February 19, 2013, 12:55:52 AM
Quote
Are you URL encoding the recipients JSON?

I think  ??? I'm doing this correctly, here is my code:

Code:
    foreach($payments as $addr){
        $add = $addr['add'];
        $addresses[add] = $addr['amount'] * 100000000;
    }
    $recipients = json_encode($addresses);

    https://blockchain.info/merchant/$guid/sendmany?password=$pass&second_password=$pass2&recipients=$recipients&anonymous=false&fee=50000
But what is actually performing the request? For instance, if you paste your original request into a browser, the browser will replace all the quotes with %22


Title: Re: Help with Blockchain API sendmany
Post by: klestor on February 19, 2013, 12:58:43 AM
Sorry I left out the request, I'm using file_get_contents().


Title: Re: Help with Blockchain API sendmany
Post by: piuk on February 19, 2013, 01:10:30 AM
Please try urlencode($recipients) e.g.

Quote

    foreach($payments as $addr){
        $add = $addr['add'];
        $addresses[add] = $addr['amount'] * 100000000;
    }

    $recipients = urlencode(json_encode($addresses));

    https://blockchain.info/merchant/$guid/sendmany?password=$pass&second_password=$pass2&recipients=$recipients&anonymous=false&fee=50000

If that doesn't work I will take a look for server side issues.


Title: Re: Help with Blockchain API sendmany
Post by: klestor on February 19, 2013, 04:26:20 AM
Thanks piuk, Do I need to urlencode() the whole string I'm requesting or just the list of recipients?

when I add urlencode() it formats my $recipient string to this:

%7B%22add1%22%3A65400%2C%22add2%22%3A65400%7D

When I send it off to get_file_contents() or use the string in a browser I still get "Unknown Error"

The browser then translates it back to:

{%22add1%22%3A65400%2C%22add2%22%3A65400}


Title: Re: Help with Blockchain API sendmany
Post by: mrvision on March 14, 2013, 06:24:28 PM
Today i'm having a problem with sendmany. If i put &from= and one of my bitcoin addresses the response it gives me is:
{"error":"You must provide at least one or more from addresses"}

If i don't put the from variable it does the job, but i want to specify the address :(

can you help me piuk?


Title: Re: Help with Blockchain API sendmany
Post by: klestor on March 15, 2013, 11:56:40 PM
mrvision, have you tried using your main wallet address?


Title: Re: Help with Blockchain API sendmany
Post by: mrvision on March 16, 2013, 07:20:35 PM
mrvision, have you tried using your main wallet address?
Yes, and it used to work... but no longer i don't know why :S