Bitcoin Forum
May 21, 2024, 12:46:33 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Help with Blockchain API sendmany  (Read 1381 times)
klestor (OP)
Newbie
*
Offline Offline

Activity: 13
Merit: 0


View Profile
February 18, 2013, 11:52:28 PM
 #1

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?

Zeilap
Full Member
***
Offline Offline

Activity: 154
Merit: 100


View Profile
February 19, 2013, 12:14:10 AM
 #2

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?
klestor (OP)
Newbie
*
Offline Offline

Activity: 13
Merit: 0


View Profile
February 19, 2013, 12:19:25 AM
 #3

yep, I've tried removing the quotes from the numbers and get {"error":"Unknown Error"}
piuk
Hero Member
*****
expert
Offline Offline

Activity: 910
Merit: 1005



View Profile WWW
February 19, 2013, 12:28:36 AM
 #4

yep, I've tried removing the quotes from the numbers and get {"error":"Unknown Error"}

Are you URL encoding the recipients JSON?

klestor (OP)
Newbie
*
Offline Offline

Activity: 13
Merit: 0


View Profile
February 19, 2013, 12:38:03 AM
Last edit: February 19, 2013, 01:00:35 AM by klestor
 #5

Quote
Are you URL encoding the recipients JSON?

I think  Huh 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);

Zeilap
Full Member
***
Offline Offline

Activity: 154
Merit: 100


View Profile
February 19, 2013, 12:55:52 AM
 #6

Quote
Are you URL encoding the recipients JSON?

I think  Huh 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
klestor (OP)
Newbie
*
Offline Offline

Activity: 13
Merit: 0


View Profile
February 19, 2013, 12:58:43 AM
 #7

Sorry I left out the request, I'm using file_get_contents().
piuk
Hero Member
*****
expert
Offline Offline

Activity: 910
Merit: 1005



View Profile WWW
February 19, 2013, 01:10:30 AM
 #8

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.

klestor (OP)
Newbie
*
Offline Offline

Activity: 13
Merit: 0


View Profile
February 19, 2013, 04:26:20 AM
 #9

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}
mrvision
Sr. Member
****
Offline Offline

Activity: 527
Merit: 250



View Profile
March 14, 2013, 06:24:28 PM
 #10

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 Sad

can you help me piuk?
klestor (OP)
Newbie
*
Offline Offline

Activity: 13
Merit: 0


View Profile
March 15, 2013, 11:56:40 PM
 #11

mrvision, have you tried using your main wallet address?
mrvision
Sr. Member
****
Offline Offline

Activity: 527
Merit: 250



View Profile
March 16, 2013, 07:20:35 PM
 #12

mrvision, have you tried using your main wallet address?
Yes, and it used to work... but no longer i don't know why :S
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!