Author

Topic: help with Bitcoin development in php (variable parameters) (Read 5965 times)

legendary
Activity: 1652
Merit: 2216
Chief Scientist
RE: other weird variable type requirments:
sendmany's second argument is a JSON Object, with string keys and number (float) values.  I think the equivalent in PHP is a PHP Array (indexed by string).

Several routines take boolean arguments.
All the rest are strings or numbers.

jr. member
Activity: 48
Merit: 9
Thank you sooooooooooooooo much!

The the problem was they were all strings.  I cast the $amount as a float and it worked!

$amount = (float)$amount;

Are there any weird variable type requirements I might run across in the other commands, or are they all strings floats and ints?
legendary
Activity: 1232
Merit: 1076

$id                Integer  No quotes
$received_address  String   Quotes
$amount            Float    No Quotes


Your problem is that $userid needs to be a string. You can cast it using (string)$userid.
full member
Activity: 176
Merit: 100
I don't know the PHP API, but a 500 error from a webserver means: "Woah, something went wrong but I can't tell what". Given that the request works if you hardcode the parameters I'd guess it is more likely, that the variables you use contain values, that are not correct. Try to output them for debugging purpose before you use sendfrom(). From what I see (guessed) the data types should be:

$id                Integer  No quotes
$received_address  String   Quotes
$amount            Float    No Quotes


I hope this helps.
jr. member
Activity: 48
Merit: 9
Hi all, I have run into some trouble using the bitcoin api with php.  When I issue a command like:

$bitcoin->sendfrom($userid, $receiving_address, $amount);

I get an error like:

fopen(http://...@localhost:8332/): failed to open stream: HTTP request failed! HTTP/1.1 500 Internal Server Error

But when I hard code in the parameters:

$bitcoin->sendfrom("1", "1LDNLreKJ6GawBHPgB5yfVLBERi8g3SbQS", 10);

it works fine.

I did notice that I had to put quotes around the variables in my parameters for other functions to work.  For example:

$bitcoin->getnewaddress("$userid");

But every combination of quotes or no quotes produces the error in the sendfrom function.

Thanks in advance for any help you can give.  Let me know if you need more info too.
Jump to: